angular-cli - npm 在安装 Angular CLI 时抛出 EACCES 错误

标签 angular-cli npm-install

我无法通过 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/

相关文章:

angular - 如何将 Fontawesome 图标放在 DataTable 按钮上? - Angular

node.js - 无法在 WIndows 中使用 npm

javascript - 当我使用 Angular cli 生成文件夹时,更改 sourceRoot 始终会生成应用程序子文件夹

firewall - 无法访问digitalocean上由Angular cli制成的Web应用程序

node.js - 我目前正在安装 "npm install --save dev webpack webpack-dev-server"但我遇到了这个问题

javascript - React安装问题npx-create-react-app无法正常工作

node.js - 将 NPM 依赖项安装到不包含 package.json 的文件夹中

npm - 找不到本地 gulp(尝试运行 : npm install gulp)

angular - index.html 没有加载本地 CSS

javascript - 有什么理由不使用提前编译?