【问题标题】:Getting permission error while trying to install @angular/cli尝试安装@angular/cli 时出现权限错误
【发布时间】:2017-10-27 04:18:05
【问题描述】:

我要在我的 Ubuntu 16.04 计算机上安装 @angular/cli。我的节点版本是 v7.10.0 和 npm 是 5.0.0

我不断收到此错误:

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: node-sass@4.5.3 (node_modules/@angular/cli/node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.5.3 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 更改权限或所有权吗?

【问题讨论】:

标签: node.js npm angular-cli npm-install


【解决方案1】:

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

目前你正在使用

/usr/local/bin/节点

尝试寻找另一个 npm:

哪里是 npm

在我的情况下,我得到了

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

然后我尝试在我的安装命令中使用另一个 npm:

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

终于安装好了。

【讨论】: