This repository has been archived by the owner. It is now read-only.

No package with compiled code (i.e C/C++/whatever) can be installed globally with npm 5 #17391

Open
mortie opened this Issue Jun 22, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@mortie

mortie commented Jun 22, 2017

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

sudo npm install -g <package>, where is one which tries to compile code on installation, fails. This is because these packages try to compile code in an install or postinstall script, but don't have write access to the directory they're ran in (/usr/lib/node_modules/<package>).

In the past, these scripts would be run with root access, because npm was ran with root access. After npm 5, these scripts fail, because they're not being ran with write access to the directory they're being installed to.

One workaround is to run sudo npm install -g --unsafe-perm <package>, but that's not great. A better solution would be for npm to execute postinstall scripts in such a way that they have write access to the directory they're currently in. For example, npm could create a temporary directory, do the install to that, including running postinstall scripts, and then move the directory over to /usr/lib/node_modules/<package>.

I would also like to mention that though this is a huge breaking change, it's not mentioned in the list of breaking changes in the changelog: http://blog.npmjs.org/post/161081169345/v500.

How can the CLI team reproduce the problem?

Run sudo npm install -g <package>, for example sudo npm install -g node-freetype. Most packages with nan as a dependency seem to also have this problem.

Here's the npm-debug.log file from running sudo npm install -g dedaemon (I didn't use sudo npm install -g node-freetype, because that never terminates as node-gyp retries indefinitely and thus never exits): https://gist.github.com/mortie/b19674ac48291e4d92ade24c34b3c576

supporting information:

  • npm -v prints: 5.0.3
  • node -v prints: v8.1.2
  • npm config get registry prints: https://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: Linux
  • Network issues: None
    • Geographic location where npm was run: Norway
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don't use a proxy, but have limited or unreliable internet access.
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.