Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm: Unhandled rejection Error: EISDIR: illegal operation on a directory, open ‘/Users/me/.npm/_cacache/content-v2/sha512/b3/da’

Tags:

npm

On my Mac, I just updated my working npm version from 5.6 to 6.9 thusly:

sudo npm i -g npm

Then I tried to install cordova like this:

sudo npm install -g cordova

And get

Unhandled rejection Error: EISDIR: illegal operation on a directory, 
open '/Users/me/.npm/_cacache/content-v2/sha512/04/89'
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/me/.npm/_logs/2019-04-02T11_50_57_678Z-debug.log

I tried to downgrade thusly:

sudo npm install -g [email protected]

but this fails with hundreds of lines like this:

npm WARN tar EISDIR: illegal operation on a directory, open '/tmp/npm-30934-a3ac319a/unpack-28da209e/bin/node-gyp-bin'
Unhandled rejection Error: EISDIR: illegal operation on a directory, open '/Users/me/.npm/_cacache/content-v2/sha512/99/72'

I also tried making sure the ownership was correct:

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

There are lots of posts of various EISDIR (error is a directory) problems for other directories (such as /usr/lib/modules), but no solutions seem to work.

Also, the npmrc file does not seem to exist. If I do:

npm config ls -l

globalconfig = "/usr/local/etc/npmrc"
userconfig = "/Users/me/.npmrc"

but neither file exists.

Note, I dont have homebrew, and didnt install it that way (I usually do manual installs).

I also tried this:

sudo npm cache clean -f

This did not help.

What else can I try? should I try deleting the ~/.npm dir?

Looking for a way to uninstall node, I found many old posts with long and sometimes conflicting lists of files to remove. Not sure if this will make it worse.

Any suggestions?

like image 617
John Little Avatar asked Jan 27 '23 12:01

John Little


1 Answers

I think I have found a solution. I did the following:

  1. installed node from the Mac pkg installer from https://nodejs.org/en/ This downgraded npm to 6.4.1 which is the version before EISDIR problems start apparently.
  2. chmod -R 777 ~/.npm/_cacache // yes, this is not good
  3. chown -R me ~/.npm/_cacache

After this, I could install cordova using "sudo npm install -g cordova" without errors.

like image 192
John Little Avatar answered May 23 '23 03:05

John Little