wd
wd copied to clipboard
Global installation fails with EACCESS error
When trying to install wd globally, as the root user, installation fails with an error:
# node --version
v8.2.1
# npm --version
5.3.0
# npm install -g wd
...
npm info lifecycle [email protected]~install: [email protected]
> [email protected] install /usr/local/lib/node_modules/wd
> node scripts/build-browser-scripts
/usr/local/lib/node_modules/wd/node_modules/mkdirp/index.js:90
throw err0;
^
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/wd/build'
at Object.fs.mkdirSync (fs.js:891:18)
at sync (/usr/local/lib/node_modules/wd/node_modules/mkdirp/index.js:71:13)
at Object.<anonymous> (/usr/local/lib/node_modules/wd/scripts/build-browser-scripts.js:6:1)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
npm info lifecycle [email protected]~install: Failed to exec install script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node scripts/build-browser-scripts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-04T10_38_27_165Z-debug.log
The log file reported above ends with these lines:
2775 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "wd"
2776 verbose node v8.2.1
2777 verbose npm v5.3.0
2778 error code ELIFECYCLE
2779 error errno 1
2780 error [email protected] install: `node scripts/build-browser-scripts`
2780 error Exit status 1
2781 error Failed at the [email protected] install script.
2781 error This is probably not a problem with npm. There is likely additional logging output above.
2782 verbose exit [ 1, true ]
This works fine in NodeJS 6
This problem is the cause of a polymer-cli installation issue: https://github.com/Polymer/polymer-cli/issues/832 , https://github.com/Polymer/polymer-cli/issues/836#issuecomment-320201006 (and probably other reports).
using --force
on the installation still displays the error, but completes the installation, after which /usr/local/lib/node_modules/wd/build
does not exist.
Here's the listing of /usr/local/lib/node_modules/wd
after a forced installation:
# ls -la /usr/local/lib/node_modules/wd/
total 60
drwxr-xr-x 1 root root 304 Aug 4 10:51 .
drwxrwxr-x 1 500 500 10 Aug 4 10:51 ..
-rw-r--r-- 1 root root 249 Apr 8 2014 .jshintrc
-rw-r--r-- 1 root root 66 Jan 27 2017 .npmignore
-rw-r--r-- 1 root root 1151 Jan 16 2017 .travis.yml
-rw-r--r-- 1 root root 584 Nov 22 2013 LICENSE.APACHE2
-rw-r--r-- 1 root root 1009 Nov 2 2015 Makefile
-rw-r--r-- 1 root root 19821 Jul 6 16:27 README.md
drwxr-xr-x 1 root root 126 Aug 4 10:51 browser-scripts
drwxr-xr-x 1 root root 340 Aug 4 10:51 doc
drwxr-xr-x 1 root root 56 Aug 4 10:51 examples
-rw-r--r-- 1 root root 8652 Jan 16 2017 gulpfile.js
-rwxr-xr-x 1 root root 105 Aug 29 2014 install-node.sh
drwxr-xr-x 1 root root 512 Aug 4 10:51 lib
drwxr-xr-x 1 root root 1962 Aug 4 10:51 node_modules
-rw-r--r-- 1 root root 3439 Aug 4 10:51 package.json
drwxr-xr-x 1 root root 48 Aug 4 10:51 scripts
drwxr-xr-x 1 root root 96 Aug 4 10:51 test
This error can be reliably reproduced using the Dockerfile
:
FROM node:8
RUN npm install -g wd
The problem appears to be with the latest version of NPM, not with NodeJS - updating NPM to version 5.3.0 on NodeJS 6 causes the same problem to occur.
I think the likely cause is a change in the file permissions that NPM uses for installing global modules from nobody
to root
(possibly the calling user's).
I still can't figure out why NPM v5.3.0 changed the file permissions of global modules to root
, but as it still runs scripts using the nobody
user (as an be seen by running npm -g config get user
) then the EACCESS
error is obvious - the script tries to create the build
directory in a root
owner directory as the nobody
user.
running npm -g config set user root
before installing works around the problem.
As details in the NPM issue linked above, the problem is a regression in NPM and can be also worked around by setting --unsafe-perm
--unsafe-perm
helped, but this has to be fixed.
https://pbs.twimg.com/media/CHKb0FSUwAIZqy5.jpg
I ran into this on Linux. Still a problem. Seems to be something that can be corrected in wd, as other packages can create folders.
Running into this same problem on OS-X High Sierra. Total pain, but --unsafe-perm allowed the install to work.
same here... linux.
The issue is still alive, see also 16 new comments for 2018 on related (closed) issue: https://github.com/Polymer/polymer-cli/issues/836.
Workaround: use --unsafe-perm
any clue when this issue will be fixed?
Any Updates? This still is a major Problem and fucks up lots of other repos that try using this. for instance web-component-tester
Everything I'm reading says that this is an NPM permissions symlink situation: https://docs.npmjs.com/getting-started/fixing-npm-permissions - does anyone actually know how I can fix this in the package? If so I would be happy to fix and do a release.
@jlipps any ideas?
It does sound like an NPM issue. Could we work around it by making sure that all files are written to /tmp? What files need writing anyway during install?