Parcel: Cannot resolve dependency

Created on 7 Dec 2017  ·  16Comments  ·  Source: parcel-bundler/parcel

index.js

const Bundler = require('parcel-bundler');

let bundler = new Bundler('input.js');

image

Bug Windows

Most helpful comment

I'm on Node 9.6 anh still get same (?) error

  Building main.css...
⏳  Building background_texture.png...
🚨  /usr/local/xx.us/xx-monolith/src/xx/static/dist/scripts/main.js:7962:27: Cannot resolve dependency './adjacency_graphs' at '/usr/local/xx.us/meta-monolith/s  7960 | frequency_lists = require('./frequency_lists');
  7961 |
> 7962 | adjacency_graphs = require('./adjacency_graphs');
       |                            ^
  7963 |
  7964 | scoring = require('./scoring');
  7965 |

All 16 comments

Does hesi-parcel\node_modules\parcel-bundler\package.json not exist?

@thejameskyle it exists

{
  "_args": [
    [
      {
        "raw": "parcel-bundler",
        "scope": null,
        "escapedName": "parcel-bundler",
        "name": "parcel-bundler",
        "rawSpec": "",
        "spec": "latest",
        "type": "tag"
      },
      "C:\\Users\\Aleksandr_Kanunnikov\\Documents\\repos\\hesi-parcel"
    ]
  ],
  "_from": "parcel-bundler@latest",
  "_id": "[email protected]",
  "_inCache": true,
  "_location": "/parcel-bundler",
  "_nodeVersion": "8.2.1",
  "_npmOperationalInternal": {
    "host": "s3://npm-registry-packages",
    "tmp": "tmp/parcel-bundler-1.0.3.tgz_1512621874216_0.6051171694416553"
  },
  "_npmUser": {
    "name": "devongovett",
    "email": "[email protected]"
  },
  "_npmVersion": "5.3.0",
  "_phantomChildren": {
    "argparse": "1.0.9",
    "arr-flatten": "1.1.0",
    "async-limiter": "1.0.0",
    "commander": "2.12.2",
    "debug": "2.6.9",
    "define-property": "1.0.0",
    "extend-shallow": "2.0.1",
    "fragment-cache": "0.2.1",
    "fs.realpath": "1.0.0",
    "inflight": "1.0.6",
    "inherits": "2.0.3",
    "is-accessor-descriptor": "0.1.6",
    "is-buffer": "1.1.6",
    "is-data-descriptor": "0.1.4",
    "minimatch": "3.0.4",
    "nanomatch": "1.2.6",
    "object.pick": "1.3.0",
    "once": "1.4.0",
    "path-is-absolute": "1.0.1",
    "path-parse": "1.0.5",
    "posix-character-classes": "0.1.1",
    "regex-not": "1.0.0",
    "repeat-element": "1.1.2",
    "repeat-string": "1.6.1",
    "safe-buffer": "5.1.1",
    "snapdragon": "0.8.1",
    "snapdragon-node": "2.1.1",
    "source-map": "0.6.1",
    "split-string": "3.1.0",
    "to-regex": "3.0.1",
    "to-regex-range": "2.1.1"
  },
  "_requested": {
    "raw": "parcel-bundler",
    "scope": null,
    "escapedName": "parcel-bundler",
    "name": "parcel-bundler",
    "rawSpec": "",
    "spec": "latest",
    "type": "tag"
  },
  "_requiredBy": [
    "#DEV:/",
    "#USER"
  ],
  "_resolved": "https://registry.npmjs.org/parcel-bundler/-/parcel-bundler-1.0.3.tgz",
  "_shasum": "5d18ff963a9b892fc910bd0bac829217d34c9459",
  "_shrinkwrap": null,
  "_spec": "parcel-bundler",
  "_where": "C:\\Users\\Aleksandr_Kanunnikov\\Documents\\repos\\hesi-parcel",
  "bin": {
    "parcel": "bin/cli.js"
  },
  "bugs": {
    "url": "https://github.com/parcel-bundler/parcel/issues"
  },
  "dependencies": {
    "babel-core": "^6.25.0",
    "babel-generator": "^6.25.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
    "babel-to-estree": "^0.0.2",
    "babylon": "^6.17.4",
    "babylon-walk": "^1.0.2",
    "browser-resolve": "^1.11.2",
    "chalk": "^2.1.0",
    "chokidar": "^1.7.0",
    "commander": "^2.11.0",
    "cssnano": "^3.10.0",
    "glob": "^7.1.2",
    "htmlnano": "^0.1.6",
    "is-url": "^1.2.2",
    "js-yaml": "^3.10.0",
    "micromatch": "^3.0.4",
    "mkdirp": "^0.5.1",
    "node-libs-browser": "^2.0.0",
    "physical-cpu-count": "^2.0.0",
    "postcss": "^6.0.10",
    "postcss-value-parser": "^3.3.0",
    "posthtml": "^0.9.2",
    "resolve": "^1.4.0",
    "serve-static": "^1.12.4",
    "uglify-js": "^3.0.28",
    "v8-compile-cache": "^1.1.0",
    "worker-farm": "^1.4.1",
    "ws": "^3.1.0"
  },
  "description": "<p align=\"center\">   <a href=\"https://parceljs.org/\" target=\"_blank\">     <img alt=\"Parcel\" src=\"https://user-images.githubusercontent.com/19409/31321658-f6aed0f2-ac3d-11e7-8100-1587e676e0ec.png\" width=\"749\">   </a> </p>",
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "cross-env": "^5.1.1",
    "less": "^2.7.2",
    "mocha": "^3.5.0",
    "ncp": "^2.0.0",
    "nib": "^1.1.2",
    "node-sass": "^4.5.3",
    "nyc": "^11.1.0",
    "postcss-modules": "^0.8.0",
    "posthtml-include": "^1.1.0",
    "rimraf": "^2.6.1",
    "stylus": "^0.54.5"
  },
  "directories": {},
  "dist": {
    "integrity": "sha512-CnOvoeIg6Z2/6LxEfH5dCXSpV0OtyDX6tR1LN1gECruJ3d5gIV0mHBSl5jn3hsMnHrgwWlTQwJO8zqIc/D90rQ==",
    "shasum": "5d18ff963a9b892fc910bd0bac829217d34c9459",
    "tarball": "https://registry.npmjs.org/parcel-bundler/-/parcel-bundler-1.0.3.tgz"
  },
  "engines": {
    "node": ">= 6.0.0"
  },
  "gitHead": "03ef0ffc66f879b2c767bd5c082289c27fc9eb4c",
  "homepage": "https://github.com/parcel-bundler/parcel#readme",
  "license": "MIT",
  "main": "index.js",
  "maintainers": [
    {
      "name": "devongovett",
      "email": "[email protected]"
    }
  ],
  "name": "parcel-bundler",
  "optionalDependencies": {},
  "readme": "ERROR: No README data found!",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/parcel-bundler/parcel.git"
  },
  "scripts": {
    "build": "babel src -d lib",
    "prepublish": "yarn build",
    "test": "cross-env NODE_ENV=test mocha"
  },
  "version": "1.0.3"
}

@lifeart - Is this still an issue after the most recent release(s)? I cannot reproduce.

@brandon93s on parcel 1.2.0 / node v7.9.0 / Win10 I get:

🚨  'super' keyword unexpected here
      return 'module.exports = ' + (yield super.load()) + ';';
                                          ^^^^^
SyntaxError: 'super' keyword unexpected here
    at NativeCompileCache._moduleCompile (C:\Users\Aleksandr_Kanunnikov\AppData\Roaming\npm\node_modules\parcel-bundler\node_modules\v8-compile-cache\v8-compile-cache.js:226:18)
    at Module._compile (C:\Users\Aleksandr_Kanunnikov\AppData\Roaming\npm\node_modules\parcel-bundler\node_modules\v8-compile-cache\v8-compile-cache.js:172:36)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (C:\Users\Aleksandr_Kanunnikov\AppData\Roaming\npm\node_modules\parcel-bundler\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Parser.findParser (C:\Users\Aleksandr_Kanunnikov\AppData\Roaming\npm\node_modules\parcel-bundler\lib\Parser.js:54:45)
    at Parser.getAsset (C:\Users\Aleksandr_Kanunnikov\AppData\Roaming\npm\node_modules\parcel-bundler\lib\Parser.js:61:22)

mark

@lifeart @davidnagli getting same thing on OSX

@lifeart same error while starting the dev,
Windows 10
npm 5.5.1
node 6.11.3

Getting same issue on parcel 1.4.1; Ubuntu 14.04.5; node v6.4.0

This is a node 6 issue. See #253 for progress. Use Node 8 for now.

I am using Parcel 1.6.2 and Node 9.4 and I'm running into this issue.

Cannot resolve dependency './dist\index.ts' at 'C:\Users\Tom\Desktop\test\dist\index.ts'

Is there anything I can do to help pin this issue down?

Me files are in / and Parcel places its files to /dist. My tsconfig.json follows:

{
  "compilerOptions": {
    "strict": true,
    "module": "es6",
    "moduleResolution": "node",
    "target": "es6",
  }
}

@TomasHubelbauer What command are you using to run Parcel? Are you manually specifying the output directory anywhere?

The issue is clearly in the ‘/‘ instead of ‘\’ on windows which uses backslashes for filepaths. We would need to figure out where that’s getting introduced (maybe it’s a problem with the TypeScript plugin?).

Sorry, I don't seem to be able to reproduce anymore (I scratch the previous state to try Rollup, now tried to redo it with Parcel and I'm having a different issue, I'll file it in separately).

How can I import/require a .txt or .html.
It just kept warning me Cannot resolve dependency.

I'm on Node 9.6 anh still get same (?) error

  Building main.css...
⏳  Building background_texture.png...
🚨  /usr/local/xx.us/xx-monolith/src/xx/static/dist/scripts/main.js:7962:27: Cannot resolve dependency './adjacency_graphs' at '/usr/local/xx.us/meta-monolith/s  7960 | frequency_lists = require('./frequency_lists');
  7961 |
> 7962 | adjacency_graphs = require('./adjacency_graphs');
       |                            ^
  7963 |
  7964 | scoring = require('./scoring');
  7965 |

I'm on Windows. I had to escape the backslash. e.g." ../dist\image-name.png". Note. This was directly in the img tag's src attribute in my index.html.

Sorry, I don't seem to be able to reproduce anymore (I scratch the previous state to try Rollup, now tried to redo it with Parcel and I'm having a different issue, I'll file it in separately).

@TomasHubelbauer What command are you using to run Parcel? Are you manually specifying the output directory anywhere?

The issue is clearly in the ‘/‘ instead of ‘\’ on windows which uses backslashes for filepaths. We would need to figure out where that’s getting introduced (maybe it’s a problem with the TypeScript plugin?).

I am not using any typescript plugin. I am facing the same issue.

My code in js file is :

if ('serviceWorker' in navigator) {
  // Use the window load event to keep the page load performant
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('./sw.js');
  });
}

and the files generated by the parcel makes it :

if ('serviceWorker' in navigator) {
  // Use the window load event to keep the page load performant
  window.addEventListener('load', function () {
    navigator.serviceWorker.register("/scripts\sw.js");
  });
}

What can be wrong here?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidnagli picture davidnagli  ·  3Comments

philipodev picture philipodev  ·  3Comments

466023746 picture 466023746  ·  3Comments

oliger picture oliger  ·  3Comments

medhatdawoud picture medhatdawoud  ·  3Comments