2017-05-26 51 views
0

我要在我的Ubuntu 16.04计算机上安装@ angular/cli。我的节点版本是 V7.10.0和NPM是5.0.0尝试安装@ angular/cli时获取权限错误

我不断收到此错误:

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/build' 
gyp ERR! System Linux 4.10.0-21-generic 
gyp ERR! command "/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 ERR! cwd /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass 
gyp ERR! node -v v7.10.0 
gyp ERR! node-gyp -v v3.6.1 
gyp ERR! not ok 
Build failed with error code: 1 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular/cli/node_modules/node-sass): 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] postinstall: `node scripts/build.js` 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 

我也尝试下面的命令:

npm cache clean --force 
sudo npm install -g @angular/cli 

我应该尝试手动和更改权限或所有权使用chmodchown

+0

您是否使用sudo拒绝了权限? –

+1

https://docs.npmjs.com/getting-started/fixing-npm-permissions –

+0

@ alex-rokabilis是的 –

回答

0

我有同样的问题。它与默认的npm有关,因为我在PC上安装了多个实例。

目前您正在使用

/usr/local/bin/node

试图找到另一个NPM:

whereis npm

在我来说,我得到了

npm: /usr/bin/npm /usr/local/bin/npm

然后我试着用另一NPM在我安装指令:

sudo /usr/bin/npm install -g @angular/cli

最后安装它。