I'm not sure if this is a problem with a newer version of Node or this package.
This is using Docker, with image FROM node:8.1
I'm trying to globally install the spectacle-docs package npm install -g spectacle-docs. It attempts to use node-gyp at one point and cannot create a directory with user "undefined", so it tries to use a local temp directory and then has an error about user "nobody", and ends up going into an infinite loop trying to rebuild.
I've tried deleting the directory and re-doing install numerous times, no luck.
Output:
> [email protected] postinstall /usr/local/lib/node_modules/spectacle-docs/node_modules/node-sass
> node scripts/build.js
Building: /usr/local/bin/node /usr/local/lib/node_modules/spectacle-docs/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli '/usr/local/lib/node_modules/spectacle-docs/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.9\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.1.2
gyp verb command install [ '8.1.2' ]
gyp verb install input version string "8.1.2"
gyp verb install installing version: 8.1.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp WARN EACCES user "undefined" does not have permission to access the dev dir "/root/.node-gyp/8.1.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/spectacle-docs/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.1.2' ]
gyp verb install input version string "8.1.2"
gyp verb install installing version: 8.1.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.1.2
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/spectacle-docs/node_modules/node-sass/.node-gyp/8.1.2
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/spectacle-docs/node_modules/node-sass/.node-gyp/8.1.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/spectacle-docs/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.1.2' ]
gyp verb install input version string "8.1.2"
gyp verb install installing version: 8.1.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.1.2
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/spectacle-docs/node_modules/node-sass/.node-gyp/8.1.2
(This will loop forever)
Same with me. I'm trying to build a docker image with a global install of the firebase-tools, which ends up needing the node-gyp.
I'm building the same image for two versions of node: 6.x (LTS ) and v8.x (latest). Locally, both images build fine, but when I try to build in docker hub only the v6.x builds successfully. With the v8.x it gets trapped in the access permissions for undefined and nobody user. I'm already using the root user (USER root), since without this setting (or using USER node) both images fail to build.
This is the Dockerfile:
FROM node:latest
USER root
RUN npm install --quiet --no-progress -g @angular/cli@latest firebase-tools
RUN npm cache clean --force
And this is part of the output:
Step 4/5 : RUN npm install --quiet --no-progress -g @angular/cli@latest firebase-tools
---> Running in fce3da11b04e
npm WARN deprecated [email protected]: Use uuid module instead
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/bin/firebase
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng
> [email protected] install /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/install.js
Unable to save binary /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:890:18)
at sync (/usr/local/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:71:13)
at Function.sync (/usr/local/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js:111:11)
at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js:154: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)
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor' }
> [email protected] install /usr/local/lib/node_modules/firebase-tools/node_modules/grpc > node-pre-gyp install --fallback-to-build --library=static_library
node-pre-gyp ERR! Tried to download(undefined): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.3.8/node-v57-linux-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI) (falling back to source compile with node-gyp)
gyp WARN EACCES user "undefined" does not have permission to access the dev dir "/root/.node-gyp/8.1.2" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp"
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp/8.1.2" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp"
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp/8.1.2" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp"
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp/8.1.2" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp"
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp/8.1.2" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/.node-gyp"
(infinite loop)
Both seem to be issues with node-sass's post-install scripts + insufficient permissions. You could try npm install --unsafe-perms (read up on what it does) but either way, I don't see anything that indicates a node-gyp bug.
The 'user "undefined"' warning is because the USER environment variable isn't set.
@bnoordhuis Indeed, I understand now that it doesn't seem to be a problem with node-gyp. But I already had set the USER to either node or root, and didn't work.
However, I was able to get it working by changing the default npm-global directory.
@kingjerod maybe it will work for you as well:
USER node
RUN mkdir /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
Doing what @gabrielaraujof suggested I could not create /var/www to copy my app files to. Tried to chmod and chown without success. Any suggestion?
Installing Angular 4 CLI on macOS: for some reason root user can't create hidden folders, folder names beginning with '.'. So cd to "/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/" in the command-line shell and do a "mkdir .node-gy." Re-run "sudo npm install -g @angular/cli." Install will finish.
@gabrielaraujof fix does not work for me.
https://gist.github.com/tknecht/33f584671eb8aaf19adb10aeded65d3c
Is there any other way to fix this
@gabrielaraujof fix helped me!
You could add --unsafe to your npm install command. npm install -g your-package --unsafe
Found it via https://github.com/npm/npm/issues/1259
Doing what @gabrielaraujof suggested I could not create /var/www to copy my app files to. Tried to chmod and chown without success. Any suggestion?
@ julianonunes
sudo mkdir /var/www? If that doesn't work does it already exist (ls -l /var/www)?
@gibfahn actually I don't remember, but what I've been using successfully so far is this:
FROM node:8.1.4
USER node
RUN mkdir /home/node/.npm-global ; \
mkdir -p /home/node/app ; \
chown -R node:node /home/node/app ; \
chown -R node:node /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
WORKDIR /home/node/app
RUN npm install
@phani1kumar add --unsafe solved the warning, thanks!
@BoiseBaked solution worked for me.
@gabrielaraujof solution worked for me as well, it's also an officially recommended way to solve permission errors. npm guide I haven't seen any actual problems when sudo install, but they recommend not to, so, I guess this is the best possible solution.
Dockerfile I used
FROM node:9.6.1 as node-angular-cli
USER node
RUN mkdir /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
RUN npm install -g @angular/cli
npm_config_user=root npm install -g ...
works for me
Doing this before npm i ... worked for me:
sed -i'' -r 's/^( +, uidSupport = ).+$/\1false/' /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js
This works for me too: https://github.com/nodejs/node-gyp/issues/1236#issuecomment-429127977
But I have no idea whether it's the right thing to do or whether there is a real bug somewhere.
npm_config_user=root npm install -g ...works for me
I added "npm config set user root" before npm install
Most helpful comment
You could add --unsafe to your npm install command.
npm install -g your-package --unsafeFound it via https://github.com/npm/npm/issues/1259