Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM dead after update - cannot find module (OSX)

Just did a minor npm update to the latest version (I can't remember what it was as npm no longer works - hence the question) but I think my installed version before the update was 5.6.0. That could be wrong though.

Anyway after running...

sudo npm install -g npm

... npm no longer works at all. Anything I do results in :

internal/modules/cjs/loader.js:596
    throw err;
    ^

Error: Cannot find module './auth.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:7:17)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)

Any suggestions?

like image 319
spice Avatar asked Mar 07 '19 17:03

spice


2 Answers

After trying a few different things including reinstalling node via brew the only thing that worked was to download and run the node installer binary from the node site.

Hope it helps somebody else.

like image 124
spice Avatar answered Oct 10 '22 23:10

spice


I fixed this issue this way:

yarn global add npm
like image 45
Alex Shushunov Avatar answered Oct 11 '22 00:10

Alex Shushunov