Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"module.js:557 throw err" when running npm from terminal

when I run npm from terminal I get this error and nothing else. no npm command is working, all of them are giving the same error and I can't even install programs that are depending on nodejs.

$ npm module.js:557 throw err; ^

Error: Cannot find module 'semver'

at Function.Module._resolveFilename (module.js:555:15)

at Function.Module._load (module.js:482:25)

at Module.require (module.js:604:17)

at require (internal/module.js:11:18)

at Object. (/usr/lib/node_modules/npm/lib/utils/unsupported.js:2:14)

at Module._compile (module.js:660:30)

at Object.Module._extensions..js (module.js:671:10)

at Module.load (module.js:573:32)

at tryModuleLoad (module.js:513:12)

at Function.Module._load (module.js:505:3)

like image 847
Deepak Surya Avatar asked Feb 10 '26 17:02

Deepak Surya


1 Answers

This did the trick for me (I'm using OSX)

sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --force node
brew install node
like image 188
fencepencil Avatar answered Feb 13 '26 10:02

fencepencil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!