angular-cli: Infinite Loop with Docker / `npm -g install @angular/cli`

Bug Report or Feature Request (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Node v8.3.0 NPM v5.3.0

OS: Docker buildpack-deps:jessie

Repro steps.

docker build

The log given by the failure.

RUN npm install -g @angular/cli

...removed...

> node-sass@4.5.3 postinstall /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /usr/local/lib/node_modules/@angular/cli/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/@angular/cli/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 node-gyp@3.6.2
gyp info using node@8.3.0 | 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.3.0
gyp verb command install [ '8.3.0' ]
gyp verb install input version string "8.3.0"
gyp verb install installing version: 8.3.0
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.3.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/@angular/cli/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.3.0' ]
gyp verb install input version string "8.3.0"
gyp verb install installing version: 8.3.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.3.0
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.3.0
gyp WARN EACCES user "nobody" does not have permission to access the dev dir "/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.3.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/@angular/cli/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.3.0' ]
gyp verb install input version string "8.3.0"

…repeating infinitely…

Note RUN npm install -g node-gyp seems to work fine.

Desired functionality.

Installs properly

Mention any other details that might be useful.

N/A

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 16
  • Comments: 18

Commits related to this issue

Most upvoted comments

This bug is still reproducible on Ubuntu Xenial and Debian Jessie. I appreciate that there is a workaround but shouldn’t the issue remain open since there is no actual fix just workarounds?

For those coming from google to quickly get around this use this command to install:

npm install -g @angular/cli --unsafe

the --unsafe gets it to complete without the loop

Still getting this in March 2018:

FROM node:8.0
RUN npm install -g @angular/cli

This spins into an infinite loop when in gets to the gyp build part. Using @PhilThurston’s --unsafe option helped me.

Why is this still a problem?

Same on MacOS High Sierra (node v8.9.4 and npm 5.6.0) below statement looping for more than 2 hours now… gyp WARN install version not already installed,, continuing with install 8.9.4

Just exited out of installation using Control+C and ng -v works fine 😃

Okay the nodejs/node-gyp#1236 trick/workaround seems to fix it:

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

Same issue with Node v9.11.1 and NPM 5.6.0

Same here. What I don’t get is why there’s no problem of user when using node 7.9.0.

For now, i’m keeping node 7.9.0.