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

时间:2019-09-24 17:27:28

标签: javascript node.js reactjs npm

我试图更新到最新版本的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

1 个答案:

答案 0 :(得分:1)

您需要许可:

sudo npm install npm@latest -g

然后输入密码