how to fix broken npm after node update - node.js

I updated node to 7.9.0 with homebrew. Now whenever I do anything with npm I get the following error:
$ node -v
v7.9.0
$ npm -v
module.js:472
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:79:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
I have tried uninstalling and reinstalling node with no change.
What can I try to recover from this?

try to remove /usr/local/lib/node_modules/npm and reinstall node again, this should work.

Related

Error: Cannot find module 'gulp-serve'

Ran the following commands...
sudo npm install --save-dev gulp-serve -globally
into the directory where gulpfile.js lives. Whenever I run sudo gulp, I receive the following error...
module.js:472
throw err;
^
Error: Cannot find module 'gulp-serve'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/www/html/bs4/gulpfile.js:2:14)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
Remove node_modules then install it without sudo:
npm i --save-dev gulp-serve

Cannot find module , Missing modules #557

After npm install -g #vue/cli#3.0.0-beta.9 ,
I run the command vue create client
I get the following output:
module.js:557
throw err;
^
Error: Cannot find module 'cmd-shim'
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.<anonymous>
(/Users/atalante/.nvm/versions/node/v9.4.0/lib/node_modules/#vue/cli/lib/util/linkBin.js:10:27)
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)
i tried rm -rf node_modules and npm install
but it doesn't work.
This usually occurs when there is an issue with either your node or npm installations, Try updating node.js and npm to resolve the issue which has worked for me in the past. This might help in updating npm : Update NPM

My npm command does not work "Cannot find module 'internal/errors'"

My npm command does not work anymore I uninstall and re install nodejs many times and still getting the same issue, so here is my console output, how can I fix this?
C:\Users\pirat>npm install
module.js:529
throw err;
^
Error: Cannot find module 'internal/errors'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at evalmachine.<anonymous>:36:16
at Object.<anonymous> (C:\Users\pirat\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\fs.js:11:1)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
C:\Users\pirat>
I re-install node version 6.11 and updated npm now is all working :)

NPM throw err 491

I have just installed node hence i run the node -v and npm -v to confirm that they have successfully been installed. node -v is returning the version of node as expected, however npm -v throws the bellow error. What can be the issue?
module.js:491
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (module.js:489:15)
at Function.Module._load (module.js:439:25)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-
cli.js:92:3)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)`
It might be a permissions problem, delete your local/lib/node_modules folder and reinstall node. For further info, you might wanna check out this error resolved on npm's github discussion.

npm version shows Error: Cannot find module 'readable-stream'

I have installed node js on my windows 7 machine, and the version is being shown as v4.1.2 but when I am trying to run npm install or even check npm version it throwing the following error. Can any one help me where is the problem?
C:\Users\nmadasu>npm version
module.js:338
throw err;
^
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\nmadasu\AppData\Roaming\npm\node_modules\npm
\node_modules\are-we-there-yet\index.js:2:14)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
After reading SO (Node.js cannot find module 'readable-stream') solutions, I tried npm install gulp -g, even this also giving same error.
C:\Users\nmadasu>npm install gulp -g
module.js:338
throw err;
^
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\nmadasu\AppData\Roaming\npm\node_modules\npm
\node_modules\are-we-there-yet\index.js:2:14)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Try:
npm install -g readable-stream
After that:
npm install gulp -g
If you can't do
npm install gulp -g
because you always have : "Cannot find module 'readable-stream'"
then, do :
sudo apt-get install npm
For me on windows the unique process that works is deleting this folders
C:\Users\YOURUSER\AppData\Roaming\npm
C:\Users\YOURUSER\AppData\Roaming\npm-cache
and Reinstall nodejs downloaded from official website
I hopoe this help to others :D

Resources