12

I updated node to 7.9.0 with homebrew. Now whenever I do anything with npm I get the following error:

$ node -v
v7.9.0
$ npm -v
module.js:472
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:79:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)

I have tried uninstalling and reinstalling node with no change. What can I try to recover from this?

1 Answer 1

27

try to remove /usr/local/lib/node_modules/npm and reinstall node again, this should work.

2
  • 1
    On mac I had to remove node as well : brew uninstall node npm
    – Ulysse BN
    Commented Dec 18, 2017 at 9:12
  • 1
    For me, I am using the n to control the node version. so the command sudo n latest will get the latest node installed and fix the broken npm issue. check this link for how to use n npmjs.com/package/n
    – Eric Tan
    Commented Nov 13, 2021 at 2:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.