sudo npm install -g npm giving bugs


(Nicolas) #1

What I Wanted to Do

update npm to the current version

What Happened Instead

npm ERR! prepareGitDep 2> npm WARN install Usage of the --dev option is deprecated. Use --only=dev instead.
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/69/1dā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/03/40ā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/57/c8ā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/b3/29ā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/2f/4dā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/12/7eā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/95/a6ā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/19/95ā€™
npm ERR! prepareGitDep Unhandled rejection Error: EISDIR: illegal operation on a directory, open ā€˜/Users/charette/.npm/_cacache/content-v2/sha512/29/1dā€™
npm ERR! prepareGitDep npm ERR! cb() never called!
npm ERR! prepareGitDep
npm ERR! prepareGitDep npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! prepareGitDep npm ERR! https://npm.community
npm ERR! prepareGitDep
npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
npm ERR! prepareGitDep npm ERR! /Users/charette/.npm/_logs/2019-03-12T22_58_11_469Z-debug.log
npm ERR! prepareGitDep
npm ERR! err.code.match is not a function

Reproduction Steps

currently at version 6.7.0 of npm. sudo npm install -g npm to update is caushing the above errors

Platform Info

$ npm --versions
{ npm: '6.7.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.32.0',
  node: '8.12.0',
  openssl: '1.0.2p',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.2',
  v8: '6.2.414.66',
  zlib: '1.2.11' }
$ node -p process.platform
  darwin

(John Gee) #2

Thanks. There is an open issue with installing global packages using sudo leaving behind files with the wrong ownership.

The short version is run this to fix the ownership, then try your install again:


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

The long version and canonical bug is: Global installs (sudo npm i -g) fail on Mac after 6.5 upgrade. Works fine after 6.4.1 downgrade.