npm 在安装 Angular CLI 时抛出 EACCES 错误 [英] npm throws EACCES error on installation of Angular CLI

查看:35
本文介绍了npm 在安装 Angular CLI 时抛出 EACCES 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过 npm 全局安装 Angular Cli.当我在 macOS 上运行 npm install -g @angular/cli 时,我不断收到此错误:

I am unable to install Angular Cli globally through npm. I keep getting this error when I run npm install -g @angular/cli on 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 时,您正在写信给您没有写入权限的目录.

When you use npm install -g on any platform and you get EACCES, you are writing to a directory for which you do not have write permission.

有些人可能会推荐使用 sudo,但这会在未来导致更多问题.npm 文档 提供了解决此问题的选项.

Some may recommend using sudo, but this will lead to more problems in the future. The npm documentation provides options to fix this.

我强烈推荐 使用 node 版本管理器如 nodeenv 作为解决方案.

I highly recommend using a node version manager like nodenv as the solution.

这篇关于npm 在安装 Angular CLI 时抛出 EACCES 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆