3

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)

fool-dev
  • 7,671
  • 9
  • 40
  • 54
Deepak Surya
  • 43
  • 1
  • 9
  • 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... https://stackoverflow.com/questions/33870520/npm-install-cannot-find-module-semver and https://github.com/coreybutler/nvm-windows/issues/302 – ayortanli Jan 21 '18 at 08:22
  • 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 Jan 22 '18 at 08:39
  • See if [https://stackoverflow.com/questions/53545800#62740853](https://stackoverflow.com/questions/53545800#62740853) helps. – Henke Jul 05 '20 at 15:28

1 Answers1

6

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
fencepencil
  • 397
  • 3
  • 8