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

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

问题描述

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

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,但这将在将来导致更多问题. npm文档提供了解决此问题的步骤.

我强烈建议使用Homebrew来安装Node的选项3.

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

解决方案

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.

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

I highly recommend option 3, using Homebrew to install Node.

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

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