This repository has been archived by the owner. It is now read-only.
Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upNo package with compiled code (i.e C/C++/whatever) can be installed globally with npm 5 #17391
Comments
mortie
referenced this issue
Jun 22, 2017
Closed
Cannot install dedaemon from NPM: dedaemon@0.2.5 postinstall fails #2
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
mortie commentedJun 22, 2017
I'm opening this issue because:
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 aninstallorpostinstallscript, 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 examplesudo 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 usesudo npm install -g node-freetype, because that never terminates as node-gyp retries indefinitely and thus never exits): https://gist.github.com/mortie/b19674ac48291e4d92ade24c34b3c576supporting information:
npm -vprints: 5.0.3node -vprints: v8.1.2npm config get registryprints: https://registry.npmjs.org/