当我尝试安装react-devtools时,我在Mac上收到此错误
Hakk-MBP:HelloWorld hakkikonu$ sudo npm install -g react-devtools
Unhandled rejection Error: EISDIR: illegal operation on a directory, open '/Users/hakkikonu/.npm/_cacache/index-v5/ad/f6'
Unhandled rejection Error: EISDIR: illegal operation on a directory, open '/Users/hakkikonu/.npm/_cacache/index-v5/da/f2'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hakkikonu/.npm/_logs/2019-02-05T14_33_58_146Z-debug.log
npm版本是:6.7.0
是什么原因?
[编辑]
我相信this link是正确的解决方案。
要么
[原始答案]
警告:这会危及安全性!它使得没有root访问权限的恶意代码可以将代码写入这些目录,并最终以root身份运行。
来自here,请不要在Mac上以sudo身份运行:
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin
然后再次尝试你的命令没有sudo。例如(在你的情况下反应 - devtools)
npm install -g npm@latest
升级到npm v6.7.0后,这解决了我的问题