npm install for package with local dependency fails

Thanks @iarna! I gave your iarna/enoent-on-link-up branch a try and it does fix the problem for me!



Any update on this issue (or above PR)? Would love for this to land. Let me know if I can help at all!


I opened another PR with tests for it as the old one seems to have stalled.


We’ve also found this in every published 6.x release. Ensuring package-lock.json isn’t present solves the issue but creates a challenge in our travis-ci builds.

@jhecking @eamodio @johnrjj @jtwebman @erikerikson Let’s vote for this issue to draw more attention from NPM team! They seem to have recently added voting functionality - it’s next to the title of the issue. Sorry for spamming :)


To reproduce using serverless-artillery we can run:

git clone --depth=50 --branch=refactor-modularize-faas Nordstrom/serverless-artillery
cd Nordstrom/serverless-artillery/
npm ci

Ran last against the commit 4c6e921b76eae4edf08698c8b565b4f663a129a0

1 Like

Neither PR appears to resolve this, unless I’ve misunderstood how to use them. I’d rate the probability of my misunderstanding to be ~0.7. I cloned the repo, switched to the branch, and ran node .../npm/cli ci.

Would this issue cause the same issue reported here: Long story short, we have a bundledDependencies entry for some-module and in our source tree, we have node_modules/some-module with the appropriate package.json and version. The only recourse right now is to use npm@4.

Have you tried the current npm@next, currently npm@6.6.0-next.0? It seems to fix the issue for me (after deleting node_modules and package-lock.json once).

1 Like

I’m using 6.6.0-next.1 and I still can’t install local dependencies.
Here is a minimal repo showing the problem:
I have two packages A and B.
A depends on B, using a local path (file:../).
B depends on left-pad (sorry :blush: ).

β”œβ”€β”€ a
β”‚   β”œβ”€β”€ package-lock.json
β”‚   └── package.json
└── b
    └── package.json

When I run npm install in package A it succeeds (there are no errors), the symlink to package B is created in node_modules (as expected) but the dependencies of B are not installed. The tree now looks like this :

β”œβ”€β”€ a
β”‚   β”œβ”€β”€ node_modules
β”‚   β”‚   └── b -> ../../b
β”‚   β”œβ”€β”€ package-lock.json
β”‚   └── package.json
└── b
    └── package.json

If I use npm ci instead of npm install it works as expected, producing the following tree:

β”œβ”€β”€ a
β”‚   β”œβ”€β”€ node_modules
β”‚   β”‚   └── b -> ../../b
β”‚   β”œβ”€β”€ package-lock.json
β”‚   └── package.json
└── b
    β”œβ”€β”€ node_modules
    β”‚   └── left-pad
    β”‚       β”œβ”€β”€ ....
    └── package.json

It also installs correctly if I remove the package-lock.json in package A.

Am I right to think that this is caused by the same bug discussed above?

Thank you for your help.


Any news on a fix for this? I too can reproduce this.


I am still hitting this error on Travis builds when using file: dependencies, and always hit it locally on subsequent npm installs as well. Looking around it seems like this has been an issue for over a year – is this slated to be fixed?

Hi! I have a similar problem (I think).

I have a project A that depends of a package B using local path (file:…). And package B has also some locals dependencies on packages C and D also with local path (file:…) something like:

β”œβ”€β”€ a
    └── package.json
         └── "b": "file:packages/b.tgz"
             └── package.json
                └── "c": "file:modules/c.tgz"
                └── "d": "file:modules/d.tgz"

I’ve tried removing all: package-lock.json, node_modules, clear npm cache, and nothing seems to work. I keep geting this error:

3037 verbose stack Error: ENOENT: no such file or directory, stat 'C:\xampp\htdocs\test-module\packages\b.tgz\modules\c.tgz'
3038 verbose cwd C:\xampp\htdocs\test-module
3039 verbose Windows_NT 10.0.17134
3040 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\abcd\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
3041 verbose node v8.12.0
3042 verbose npm  v6.9.0
3043 error path C:\xampp\htdocs\test-module\packages\b.tgz\modules\c.tgz
3044 error code ENOENT
3045 error errno -4058
3046 error syscall stat
3047 error enoent ENOENT: no such file or directory, stat 'C:\xampp\htdocs\test-module\packages\b.tgz\modules\c.tgz'
3048 error enoent This is related to npm not being able to find a file.
3049 verbose exit [ -4058, true ]

Any help?
Thanks :slight_smile:

1 Like

While I can neither confirm or deny if the original issue has been resolved, I can confirm that on npm v6.9.0, the issue persists if the dependency has a symlink in its path.

8771 verbose stack Error: ENOENT: no such file or directory, rename '/Users/sohrab/workspaces/myworkspace/myapp/server/node_modules/.staging/@company/fastify-openapi-cfdde382/node_modules/@babel/cli' -> '/Users/sohrab/workspaces/myworkspace/myapp/server/node_modules/.staging/@babel/cli-e2c46704'
8772 verbose cwd /Users/sohrab/workspaces/myworkspace/myapp/server
8773 verbose Darwin 18.5.0
8774 verbose argv "/Users/sohrab/.nvm/versions/node/v10.15.3/bin/node" "/Users/sohrab/.nvm/versions/node/v10.15.3/bin/npm" "update" "nyc" "mocha"
8775 verbose node v10.15.3
8776 verbose npm  v6.9.0
8777 error path /Users/sohrab/workspaces/myworkspace/myapp/server/node_modules/.staging/@company/fastify-openapi-cfdde382/node_modules/@babel/cli
8778 error code ENOENT
8779 error errno -2
8780 error syscall rename
8781 error enoent ENOENT: no such file or directory, rename '/Users/sohrab/workspaces/myworkspace/myapp/server/node_modules/.staging/@company/fastify-openapi-cfdde382/node_modules/@babel/cli' -> '/Users/sohrab/workspaces/myworkspace/myapp/server/node_modules/.staging/@babel/cli-e2c46704'
8782 error enoent This is related to npm not being able to find a file.
8783 verbose exit [ -2, true ]

When using file: dependency to a symlink directory:

"dependencies": {
    "@company/fastify-openapi": "file:../fastify-openapi",

My current workaround is to keep deleting package-lock.json.

1 Like

I have same issue.

Current workarounds:

  • Remove package-lock.json
    • Probably, This issue will be happened when package-lock.json does exist.
  • Use yarn (+ workspaces) or yarn + link: protocol
  • Use lerna + npm
    • But, This combination does not work with dependency maintaince service like dependabot aka. GitHub Security Alert

My motivation for using npm + file: is that it work with dependabot.
But, itself(npm + file:) does not work correctly.

I’m currently using webpack resolve alias as a workaround which works quite well:

This is still happening in npm 6.11.3. The only β€œsolution” I found was removing package-lock.json.

This might be the same bug and has a reproducible example: ENOENT error when the same package appears in local dependencies

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.