Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

新换的笔记本,在安装yarn 的时候报错了, 错误如下图所示:

Last login: Tue Dec 15 10:01:00 on console

appledeMacBook-Pro:~ apple$ npm install -g yarn

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

npm ERR! code EACCES

npm ERR! syscall access

npm ERR! path /usr/local/lib/node_modules

npm ERR! errno -13

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {

npm ERR!   errno: -13,

npm ERR!   code: 'EACCES',

npm ERR!   syscall: 'access',

npm ERR!   path: '/usr/local/lib/node_modules'

npm ERR! }

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.

npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/apple/.npm/_logs/2020-12-15T07_47_24_728Z-debug.log

问题原因:

npm的错误提示已经指出了原因:Error: EACCES: permission denied (权限不够)

并给出了建议 :Please try running this command again as root/Administrator.(使用管理员权限)

解决办法:

使用加上sudo的npm命令(sudo: 申请root 权限)

sudo npm install -g yarn

有时候就是英文不好,一直在想这要是外语好的人根本不叫事。看来学习外语真的需要提上日程了。

站内部分资源收集于网络,若侵犯了您的合法权益,请联系我们删除!
赞赏是最好的支持
如果对你有帮助那就支持一下吧
立即赞赏
分享到:
赞(6) 打赏

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

小月博客-一个专注于分享的技术博客
没有账号? 忘记密码?