使用npm install -g @angular/cli安装CLI时出现以下错误:

3
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:
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! 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!     /home/guru/.npm/_logs/2018-10-24T16_44_52_889Z-debug.log
1个回答

1
在 Mac 或 Linux 上,当您收到错误消息 Permission denied 时,请使用 sudo
sudo npm install

在Windows上,只需使用管理员身份运行命令提示符、bash或powershell即可。


SUDO是MAC的一个命令,类似于“以管理员身份运行”,如果你在WINDOWS上,则只需执行NPM INSTALL。 - mruanova

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接