Unable to install n

What I Wanted to Do

I want to install n globally.
sudo npm install n -g

What Happened Instead

Unhandled rejection Error: EISDIR: illegal operation on a directory, open β€˜/Users/XXX/.npm/_cacache/index-v5/b0/67’

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/XXX/.npm/_logs/2019-06-30T02_53_22_662Z-debug.log

Reproduction Steps

OS Mac OS Mojave
NPM: 6.9.2

Sequence of commands
sudo npm cache clean -f
sudo npm install n -g


Debug log

0 info it worked if it ends with ok
1 verbose cli [ β€˜/Users/XXX/.nvm/versions/node/v8.12.0/bin/node’,
1 verbose cli β€˜/Users/XXX/.nvm/versions/node/v8.12.0/bin/npm’,
1 verbose cli β€˜install’,
1 verbose cli β€˜n’,
1 verbose cli β€˜-g’ ]
2 info using npm@6.9.2
3 info using node@v8.12.0
4 verbose npm-session 37cf5d9a19204fbd
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 timing npm Completed in 1877ms
8 error cb() never called!
9 error This is an error with npm itself. Please report this error at:
10 error https://npm.community

Platform Info

$ npm --versions
{ npm: '6.9.2',
  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

This issue might be fixed by upgrading to node v10.6 or higher, if that is an option for you. Given you were trying to install n anyway, here are some instructions to try the upgrade using n.

# Download n to current directory
curl -L https://github.com/tj/n/raw/master/bin/n -o n
# Use n to install node (and npm)
sudo bash ./n lts
# Now use npm to install n, fingers crossed
sudo npm install -g n

Note also: there are some approaches on how to use n (and npm i -g) without needing to use sudo in the README: https://github.com/tj/n#installation

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.