安装Angular时出现权限问题

时间:2019-07-24 09:33:50

标签: node.js angular terminal

我要在MAC书上安装节点和角度。已安装Node.js,节点版本为v10.16.0

现在我正在安装角钢,所以我尝试了

npm install -g @angular/cli

但是我遇到一些权限错误。

quesBank-MacBook-Air:~ quesBank$ node -v
v10.16.0
quesBank-MacBook-Air:~ quesBank$ npm install -g @angular/cli
npm WARN checkPermissions Missing write access to /Users/quesBank/.npm-global/lib/node_modules/@angular/cli
npm ERR! path /Users/quesBank/.npm-global/lib/node_modules/@angular/cli
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/quesBank/.npm-global/lib/node_modules/@angular/cli'
npm ERR!  { [Error: EACCES: permission denied, access '/Users/quesBank/.npm-global/lib/node_modules/@angular/cli']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/Users/quesBank/.npm-global/lib/node_modules/@angular/cli\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/Users/quesBank/.npm-global/lib/node_modules/@angular/cli' }
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!     /Users/quesBank/.npm/_logs/2019-07-24T09_14_12_078Z-debug.log
quesBank-MacBook-Air:~ quesBank$ 

然后我在命令下面尝试了

sudo chown -R $USER /usr/local/lib/node_modules

它要求输入密码,然后我检查了ng --version

quesBank-MacBook-Air:~ quesBank$ ng --version
-bash: ng: command not found

quesBank-MacBook-Air:~ quesBank$ 

您能帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:0)

如果您是通过从Node网站下载安装程序包在Mac上安装Node的,则此选项会在更高版本的macOS上产生权限错误(我从Sierra开始我认为)。真气!

如果能够完全卸载Node(绝非易事),则可以通过Homebrew重新安装它,这将自动解决权限问题。

但是,由于在Mac上完全卸载Node并不是特别容易(尽管有些有用的注释者可能证明我错了!),您可以按照以下指南进行操作:

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

遵循本指南,您可以进行全局npm安装而没有任何其他问题,尽管缺点是您有时必须运行source ~/.profile(本指南中说明了.profile)才能访问全局Node模块。

答案 1 :(得分:0)

尝试 Id => "username", NodeType => "ELEMENT_NODE", NodeName => "INPUT", Class => "login-input input-style">", Value => null, WebView => "NoResourceEntry-11",