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

npm installing to global gives Error: ENOENT, No such file or directory #8545

Closed
jonathan-kosgei opened this issue Sep 15, 2016 · 4 comments
Closed
Labels
npm Issues and PRs related to the npm client dependency or the npm registry.

Comments

@jonathan-kosgei
Copy link

jonathan-kosgei commented Sep 15, 2016

I'm running node/npm in a chroot on alpine linux.

I get the following error installing to global with the following command:

/ # chroot /ns npm install pm2@latest -g
Error: ENOENT, No such file or directory
    at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:49:16
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
/ # chroot /ns npm install pm2@latest 
npm ERR! makeDirectory homeless?
npm ERR! Linux 4.4.0-36-generic
npm ERR! argv "node" "/usr/bin/npm" "install" "pm2@latest"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3

npm ERR! Cannot read property 'uid' of undefined
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
^C

This works:

/ # chroot /ns npm install pm2
....install....
npm WARN optional Skipping failed optional dependency /pm2/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
@gibfahn gibfahn added invalid Issues and PRs that are invalid. npm Issues and PRs related to the npm client dependency or the npm registry. labels Sep 15, 2016
@gibfahn
Copy link
Member

gibfahn commented Sep 15, 2016

This seems like an npm issue, if so could you raise an issue directly with npm (i.e. here)?

If you think this is a node specific problem, feel free to reply on this thread.

@gibfahn gibfahn closed this as completed Sep 15, 2016
@imyller
Copy link
Member

imyller commented Sep 15, 2016

It's true that this is npm issue, but since we ship npm as part of Node.js I'm trying to help out:

You should try running npm with --unsafe-perm flag which suppresses the UID/GID switching when running package scripts.

npm ERR! Cannot read property 'uid' of undefined is raised because your chrooted environment /etc/passwd file does not contain the uid npm is trying to switch to.

So, two possible workarounds:

  • Create appropriate user/group /etc/passwd and /etc/group to your chroot
  • Use --unsafe-perm flag with npm

@imyller imyller removed the invalid Issues and PRs that are invalid. label Sep 15, 2016
@jonathan-kosgei
Copy link
Author

jonathan-kosgei commented Sep 15, 2016

@imyller You're right about the /etc/passwd & /etc/group. I was previously using touch to creating them but now I'm copying them over to the chroot and the second case chroot /ns npm install pm2@latest works.

Running npm with -g and --unsafe-perm , the following works as well!

/ # chroot /ns npm install pm2@latest -g --unsafe-perm

Why does using --unsafe-perm work? I'm I missing some basic configuration in the chroot environment that npm needs?

Also, what does npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14 mean?

Thanks!

@imyller
Copy link
Member

imyller commented Sep 15, 2016

Why does using --unsafe-perm work? I'm I missing some basic configuration in the chroot environment that npm needs?

It works because with that flag npm does not need to access /etc/passwd or /etc/group files at all. UID/GID switching is disabled.

As I said earlier, you can alternatively create dummy passwd/group files with appropriate system users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm Issues and PRs related to the npm client dependency or the npm registry.
Projects
None yet
Development

No branches or pull requests

3 participants