npm: 权限阻止修复

在使用 npm install 时,总提示:

Error: EACCES: permission denied

今天通过这个命令设置了权限解决了问题:

sudo chown -R $(whoami) ~/.npm

方法来自:https://stackoverflow.com/a/51923345/1185971

---

在安装 node-gyp 时提示:

Unhandled rejection Error: EISDIR: illegal operation on a directory, open '/Users/baidu/.npm/_cacache/tmp'

npm ERR! cb() never called!

采用上文方法处理后,又提示:

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

于是,又执行了一个:

sudo chown -R $(whoami)  /usr/local/lib/node_modules

解决~


[恰饭]教程推荐:

不会 js 断点调试?看这里, 一碗面的成本,掌握知识和姿势~


原文地址:https://www.cnblogs.com/duxing/p/10521743.html