Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix broken npm after node update

Tags:

node.js

npm

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?

like image 951
zorro2b Avatar asked Apr 24 '17 00:04

zorro2b


People also ask

Why is my npm not working?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

Does upgrading node upgrade npm?

In Windows, you can simply download the newest version of node and install it. It'll upgrade both node and npm.


1 Answers

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

like image 112
Pablo Cesar Cordova Morales Avatar answered Sep 20 '22 14:09

Pablo Cesar Cordova Morales