无法在Linux上安装@ angular / cli

时间:2017-07-13 14:10:31

标签: node.js linux npm angular-cli

当我执行命令时:npm install -g @angular/cli我收到错误:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/my_user_name/.npm/_logs/2017-07-13T13_36_06_285Z-debug.log

然后我尝试执行命令:sudo npm install -g @angular/cli但我收到错误:

npm ERR! path /usr/local/bin/ng
npm ERR! code EEXIST
npm ERR! Refusing to delete /usr/local/bin/ng: ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by npm /usr/local/bin
npm ERR! File exists: /usr/local/bin/ng
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/my_user_name/.npm/_logs/2017-07-13T13_39_01_642Z-debug.log

如果甚至sudo特权还不够,我该如何安装Angular-CLI?

1 个答案:

答案 0 :(得分:1)

看起来像是写问题。

您有两种方法可以使用sudo(不是最佳选项)或更改文件夹所有者。

  1. sudo npm install -g @angular/cli
  2. sudo chown -R $USER /usr/local/lib/node_modules
  3. 检查内容符号链接路径最终重新安装双重性设置权限。