Error installing Angular 2 CLI

1.1k Views Asked by At

I'm trying to install the Angular 2 CLI on a El Capitan machine with: node 7.10.0 and npm 5.0.

I get the following recursive error during installation:

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.0.0' ]
gyp verb install input version string "8.0.0"
gyp verb install installing version: 8.0.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.0.0
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.0.0
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.0.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.0.0' ]
gyp verb install input version string "8.0.0"
gyp verb install installing version: 8.0.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.0.0
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.0.0
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.0.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.0.0' ]
gyp verb install input version string "8.0.0"
gyp verb install installing version: 8.0.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.0.0
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.0.0
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.0.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.0.0' ]
gyp verb install input version string "8.0.0"
gyp verb install installing version: 8.0.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.0.0
gyp verb ensuring nodedir is created /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.0.0

I've uninstalled it by using

sudo npm uninstall -g @angular/cli

and reinstalled it by using

sudo npm install -g @angular/cli

Insight into what may be causing this and how to fix it?

2

There are 2 best solutions below

0
atherton On

sudo npm install --unsafe-perm --verbose -g @angular/cli

Did the trick. Workaround works for now.

0
Huske On

Another way to resolve this is to install gyp and @angular/cli explicitly.

sudo npm install gyp @angular/cli -g

If it fails again, try to install gyp first and then the CLI.