角安装cli errno -13

时间:2019-08-04 05:27:26

标签: node.js angular 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!   stack: '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! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/admin/.npm/_logs/2019-08-04T05_20_10_235Z-debug.log

反复尝试以下命令仍然无法正常工作。

1-我卸载nodejs并重新安装旧版本

~ brew uninstall node 
~ which node
~ rm -rf /usr/local/bin/node
  ~cd /usr/local/lib
     ~ sudo rm -rf node
      ~ sudo rm -rf node_modules

2-清洁现金

~ npm cache verify --force
~ npm cache clear --force 
~ npm uninstall -g @angular/cli
~ npm install -g @angular/cli

节点版本 v8.16.0

npm版本 6.4.1

3 个答案:

答案 0 :(得分:0)

Angular 8的最新版本以来,它需要Node.js 10.9.0或更高版本。

在您的操作系统上升级Node.js

查看文档以设置您的环境:https://angular.io/guide/setup-local

答案 1 :(得分:0)

从错误消息看来,文件夹没有写许可权。

如果您使用的是Windows计算机,请在“以管理员身份运行”中打开命令提示符,然后执行命令。

如果您使用的是Mac,则必须使用chmod 777 /usr/local/lib/node_modules

授予其权限

答案 2 :(得分:0)

在linux上,我不得不使用sudo npm install ...