未处理的拒绝错误:EISDIR:目录上的非法操作

时间:2019-02-05 14:36:08

标签: npm npm-install

我在尝试安装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

原因是什么?

1 个答案:

答案 0 :(得分:12)

here中,不要在Mac上以sudo的身份运行:

sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin

然后在没有sudo的情况下重试您的命令。例如(您的情况下为react-devtools)

npm install -g npm@latest

这解决了我升级到npm v6.7.0后的问题