3
votes

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)

1
Your npm module may be corrupted or some not suitable module versions are installed. I heard similar problems earlier. Take a look at those urls for workaround solutions at least... stackoverflow.com/questions/33870520/… and github.com/coreybutler/nvm-windows/issues/302ayortanli
I updated semver manually and the problem was fixed, but i got another error "cb() never called" so i was fed up and switched to yarn package manager. Either way, thanks bruh!Deepak Surya

1 Answers

6
votes

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