angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

cli won't install on ubuntu 16.04 without installing node-gyp manually

Open rotemfogel opened this issue 9 years ago • 23 comments

Bug Report or Feature Request (mark with an x)

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

Versions.

$ ng -v; node -v; npm -v
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.1.2
node: 8.1.2
os: linux x64
v8.1.2
5.0.3

Repro steps.

  • install ubuntu 16.04
  • install nodejs (using apt) sudo apt-get install -y nodejs
  • install @angular/cli sudo npm install -g @angular/cli

The log given by the failure.

@angular/cli refuses to install, saying root user is not allowed to write into /usr/lib/node_modules/.... The install process retries endlessly.

Desired functionality.

@angular/cli to check if node-gyp is installed an either fail saying requirement missing or install it by itself

Mention any other details that might be useful.

A fix for the issue, is manually installing node-gyp prior to installing @angular/cli

$ sudo npm install -g node-gyp
$ sudo npm install -g @angular/cli

rotemfogel avatar Jun 18 '17 14:06 rotemfogel

@rotemfogel you should not be installing npm packages using sudo. https://docs.npmjs.com/getting-started/fixing-npm-permissions

nikoTM avatar Jun 19 '17 11:06 nikoTM

@nikoTM this is not a question whether "you should' or "you should not'... the default node/npm installation forces sudo usage under Ubuntu. BTW: does your suggestion solve the issue?

UniK avatar Aug 02 '17 06:08 UniK

Confirm, the sudo npm install -g @angular/cli produces an infinite installation loop under Ubuntu with default access permissions under /usr/lib/node_modules.

UniK avatar Aug 02 '17 07:08 UniK

Same issue over here

hmarcelodn avatar Aug 07 '17 20:08 hmarcelodn

I'm having the same issue as @UniK .

cameronfarvin avatar Aug 18 '17 02:08 cameronfarvin

I have the same issue on Ubuntu 16.04 and installing the gyn before did not fix the problem gyp verb install version not already installed, continuing with install 8.7.0 gyp verb ensuring nodedir is created /usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.7.0 gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.7.0" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/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.7.0' ] gyp verb install input version string "8.7.0" gyp verb install installing version: 8.7.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.7.0 gyp verb ensuring nodedir is created /usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.7.0 gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.7.0" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/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.7.0' ] gyp verb install input version string "8.7.0" gyp verb install installing version: 8.7.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.7.0 gyp verb ensuring nodedir is created /usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.7.0 gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.7.0" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp" gyp verb^C

devsparkles avatar Oct 23 '17 11:10 devsparkles

I did that: $ sudo rm -Rf @angular/ node-gyp $ sudo npm install -g node-gyp /usr/bin/node-gyp -> /usr/lib/node_modules/node-gyp/bin/node-gyp.js

  • [email protected] added 102 packages in 2.298s Then open a new terminal and sudo npm install -g @angular/cli Got AGAIN the LOOP Mayhem problem the retry and got a success..... sudo npm install -g @angular/cli /usr/bin/ng -> /usr/lib/node_modules/@angular/cli/bin/ng npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular/cli/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

  • @angular/[email protected] updated 2 packages in 50.573s


more information node -v v8.7.0 npm -v 5.4.2

devsparkles avatar Oct 23 '17 11:10 devsparkles

Experiencing the same issue and like @devsparkles found that cancelling the angular/cli install once it hits its infinite loop and re-running the same command fixes the issue.

In my case, I was running this as a gitlab build job and not interactively so I had to script this. If anyone else is this unfortunate position while waiting for the issue to be resolve... the script snippet is below (it sure is ugly but it may get you out of a hole!)

npm install -g node-gyp timeout 120 npm install -g @angular/cli > /dev/null npm install -g @angular/cli the timeout line is the script equivalent of letting it partially install and then ctrl+C when it gets in its nasty loop state.

Repo steps: docker run -it node:latest /bin/bash Note: by default you will be running as root which may be part of the issue

npm install -g @angular/cli

node -v v8.5.0 npm -v 5.3.0

Bazmcl avatar Nov 15 '17 11:11 Bazmcl

formatted script npm install -g node-gyp timeout 120 npm install -g @angular/cli > /dev/null npm install -g @angular/cli

Bazmcl avatar Nov 15 '17 11:11 Bazmcl

On my Ubuntu it worked fine by first installing node-gyp. On another machine with Debian8 all solutions listed here failed, the only one which worked in this case was sudo npm install --unsafe-perm -g @angular/cli

Valerski-Emilija avatar Nov 19 '17 12:11 Valerski-Emilija

having the same issue on Mac OS high sierra. npm: 5.5.1 node:8.9.1 following the steps listed here resolved the issue.

LenonLopez avatar Nov 19 '17 20:11 LenonLopez

Same issue on ubuntu 17.04. Installing @angular/cli through npm makes it go into an infinite loop giving an EACCESS error saying user "root" doesn't have enough permissions to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.9.1" and then it tries reinstalling from the temporary dev directory and this goes on forever...

BK1603 avatar Dec 20 '17 15:12 BK1603

Spent lot of time on this issue, even I had the same issue, tried everything suggested over here, clear npm cache as well, please read the bl0g below to install nvm https://github.com/creationix/nvm/blob/master/README.md#installation Even this helped a lot, Once you install nvm enter nvm use node in terminal and then use sudo npm install -g @angular/cli

akshayr20 avatar Dec 31 '17 04:12 akshayr20

i faced same issue .any update to solve this ?

vamshi9666 avatar Mar 20 '18 17:03 vamshi9666

Install NVM (node version manager), then install angular it solves this issue..

akshayr20 avatar Mar 20 '18 17:03 akshayr20

i installed it . actually that's where everything is messed up . before i created new components with ng . but then after installation of nvm .it got messed everything

vamshi9666 avatar Mar 21 '18 15:03 vamshi9666

now i was able to use ng commands . i just removed node,npm and nvm .everything is running well now .

vamshi9666 avatar Mar 21 '18 15:03 vamshi9666

Had similar infinite loop while installing @angular/cli in docker environment (using FROM node:8.11.1 ). The only solution that worked for me was using the --unsafe-perm switch while installing angular cli.

alkeicam avatar Apr 11 '18 12:04 alkeicam

Still getting an infinite loop while installing @angular/cli on 64bit Ubuntu 16.04. Problem solved by installing node-gyp first.

parthsuresh avatar Apr 22 '18 09:04 parthsuresh

thanks to @xvalerijus , that command solved my problem.

But how to clean up the mess, which takes lots of my disk space. And "npm cache clean" does not work!

maiziheimei avatar May 03 '18 17:05 maiziheimei