尝试更新npm时出现权限问题

3
我尝试更新到最新版本的npm,但出现了这个错误?有人以前遇到过npm权限错误吗?我不知道如何解决。
marshalls-MacBook-Air:Desktop marshall$ npm install npm@latest -g
npm WARN checkPermissions Missing write access to /usr/local/Cellar/node/11.9.0/lib/node_modules
npm ERR! path /usr/local/Cellar/node/11.9.0/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/Cellar/node/11.9.0/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/Cellar/node/11.9.0/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/Cellar/node/11.9.0/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/Cellar/node/11.9.0/lib/node_modules' }
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/marshall/.npm/_logs/2019-09-24T17_21_36_708Z-debug.log

2
在命令前使用 sudo - Shumail
1个回答

2

您需要权限:

sudo npm install npm@latest -g

接着输入您的密码。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接