5

I am trying to install express-generator using npm install express-generator -g. However I'm getting errors.

WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/ejs-2de19af3/lib'026584d.lock for /usr/local/lib/node_modules/.staging
WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/sorted-object-b497dff3/lib'
WARN tar EISDIR: blah blah many more lines like this
WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/mkdirp-f65a1b18/test'

npm ERR! path /usr/local/lib/node_modules/express-generator/node_modules/mkdirp/bin/cmd.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/express-generator/node_modules/mkdirp/bin/cmd.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xXc00lUs3rXx/.npm/_logs/2019-01-04T03_45_41_388Z-debug.log

I'm not sure what the EISDIR warnings are about, but for the ENOENT chmod error it is trying to access /usr/local/lib/node_modules/express-generator/ but there is no such directory.

I am running npm on Mac. I'm not sure how to resolve this issue.

Increasingly Idiotic
  • 5,700
  • 5
  • 35
  • 73

2 Answers2

2

Try next commands: 1) sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} It changes owner of lib/node_modules,bin,share to your macos user 2) npm install express-generator -g After the first step you don't need to use 'sudo' when install in global more.

Sanchonn
  • 179
  • 6
1

I was just in the same boat. What version of NPM are you running? According to this thread, NPM@6.5 may be causing global NPM installs to fail. I ran into even more errors trying to downgrade to NPM@6.4.1 and ended up uninstalling and reinstalling Node. I'm back on NPM@6.5 and everything is back to normal.

devonw
  • 48
  • 6