我无法通过 npm 全局安装 Angular Cli。
当我运行 npm install -g @angular/cli
时,我不断收到此错误在 macOS 上:
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
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! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! at Error (native)
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! Please include the following file with any support request:
npm ERR! /Users/apple/npm-debug.log
最佳答案
当您使用 npm install -g
在任何平台上,您都会得到 EACCES
,您正在写入一个您没有写入权限的目录。
有些人可能会推荐使用 sudo
,但这会导致 future 更多的问题。 npm documentation提供了解决此问题的选项。
我强烈推荐 using a node version manager like nodenv作为解决方案。
关于angular-cli - npm 在安装 Angular CLI 时抛出 EACCES 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42042300/