Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm install as root fails with lots of ENOENT, when node_modules is owned by different user on 6.11-6.13.0 #286

Closed
OJezu opened this issue Nov 6, 2019 · 6 comments
Labels
Awaiting Information further information is requested Bug thing that needs fixing

Comments

@OJezu
Copy link

OJezu commented Nov 6, 2019

What / Why

npm 6.13.0 spews a lot of ENOENT when node_modules directory does not exist, it also fails to download private packages from git

When

  • on every dokcerized build in our CI, as there is no node_modules directory in repo from which code is cloned
  • repo files are downloaded and created by uid 1000, but npm is run as root in container
  • also 100% reproducible for our application when run from terminal

Where

  • n/a

How

Current Behavior

  • with no node_modules directory (parent directory owned by uid 1000):
# rm -rf node_modules; npm install
npm WARN tar ENOENT: no such file or directory, open '/snip/node_modules/.staging/gulp-32c60be4/package.json'
npm WARN tar ENOENT: no such file or directory, open '/snip/node_modules/.staging/gulp-32c60be4/README.md'
npm WARN tar ENOENT: no such file or directory, open '/snip/node_modules/.staging/gulp-32c60be4/LICENSE'
(... there are tens of those ENOENTs)
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@<private server>/admin-template.git
npm ERR! 
npm ERR! No user exists for uid 1000
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! 
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-11-06T11_08_52_469Z-debug.log
  • with (empty) node_modules directory (created by root):
# rm -rf node_modules; mkdir node_modules; npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 921 packages from 509 contributors and audited 4933 packages in 17.315s

Steps to Reproduce

  • rm -rf node_modules; npm install

Expected Behavior

  • node_modules is created before packages are written to it, npm install runs the same no matter if there is no node_modules or empty node_modules directory

Who

  • n/a

References

  • n/a
@OJezu
Copy link
Author

OJezu commented Nov 6, 2019

npm@6.12.1 fails
npm@6.11.3 fails
npm@6.10.3 is fine
npm@5.10.0 is fine

@OJezu OJezu changed the title [BUG] npm 6.13.0 install fails with lots of ENOENT, when node_modules directory does not exist [BUG] npm install fails with lots of ENOENT, when node_modules directory does not exist on 6.11-6.13.0 Nov 6, 2019
@OJezu
Copy link
Author

OJezu commented Nov 6, 2019

Same behaviour seems to occur, if node_modules directory already exists, but is owned by different user.

@OJezu
Copy link
Author

OJezu commented Nov 6, 2019

This seems to be combination of:

  • npm running as root (in container)
  • root not owning node_modules directory, or parent directory if node_modules does not exist
  • there is no user who owns those directories in container (uid 1000, and no entry in /etc/passwd)
  • downloading some packages with git+ssh from remote repository

@OJezu OJezu changed the title [BUG] npm install fails with lots of ENOENT, when node_modules directory does not exist on 6.11-6.13.0 [BUG] npm install as root fails with lots of ENOENT, when node_modules is owned by different user on 6.11-6.13.0 Nov 6, 2019
@darcyclarke darcyclarke added the Awaiting Information further information is requested label Nov 6, 2019
@taborlin5
Copy link

Having the same issue

@doochik
Copy link

doochik commented Nov 7, 2019

I have the same issue.

My case:

  • teamcity runs docker container and mounts repo inside
  • run npm ci as root inside container
  • npm (or git) fails with No user exists for uid NNNN. NNNN is UID of teamcity user at host server

npm < 6.11 works fine. This issue may be related to this commit 8b85eaa

@darcyclarke darcyclarke added the Bug thing that needs fixing label Nov 8, 2019
@darcyclarke darcyclarke modified the milestone: OSS - Sprint 17 Oct 5, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Information further information is requested Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

4 participants