hakki
hakki

Reputation: 6519

Unhandled rejection Error: EISDIR: illegal operation on a directory

I'm getting this error on my Mac when I try to install react-devtools

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 version is: 6.7.0

What is the reason?

Upvotes: 3

Views: 10050

Answers (1)

Pieter
Pieter

Reputation: 2239

[edit]

I believe this link is the correct solution.

  1. Reinstall npm with a node version manager (recommended)

or

  1. Manually change npm’s default directory

[original answer]

WARNING: this compromises security! It makes it possible for malicious code running without root access to write code into these directories, where it may end up running as root.

From here, don't run as sudo on Mac:

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

Then try your command again without sudo. e.g. (react-devtools in your case)

npm install -g npm@latest

This solved the provblem for me after upgrading to npm v6.7.0

Upvotes: 17

Related Questions