Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module 'update-notifier'

Everytime time I run npm on mac terminal, I've got this error

Mac01:~ qa$ npm
module.js:515
    throw err;
    ^

Error: Cannot find module 'update-notifier'
    at Function.Module._resolveFilename (module.js:513:15)
    at Function.Module._load (module.js:463:25)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:29:19
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)

-> http://prntscr.com/h1r3yu

how can i solve that?

like image 538
JSN Avatar asked Oct 18 '22 03:10

JSN


1 Answers

Ran into this issue. Even a simple npm --version was bombing with the same message. This lead me on a wild goose chase of brew uninstalls, symlink errors, rm's to remove files /node_modules/npm & /node, chowning directories -- you get the gist. Unsure the root cause of my brew-failings, but it might be related to npm being installed as standalone prior, whereas node now includes npm, which lead to brew config-hell on my machine.
I suggest the tips above, but if all else fails, what worked for me was to uninstall via brew, then go to the https://nodejs.org/en/download site and re-install. Believe me, I don't want to get out of terminal and not use brew, but in this case, this was the only solution that worked for me.

  • Uninstall node via brew : brew uninstall --ignore-dependencies node or brew uninstall --force node
  • Go to https://nodejs.org/en/download download and reinstall.
  • Now test to see if the error is gone with a npm --version
like image 158
AM_FM Avatar answered Oct 20 '22 05:10

AM_FM