Error: Cannot find module 'readable-stream' - node.js

I was using npm few days ago and all worked fine, but I'm suddenly getting an error when trying to do any npm command.
module.js:487
throw err;
^
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js:3:14)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
I can't do any npm command, even npm -v show this error, node version is 8.0.0
I'm using latest version of macOS
One of the problems is that I didn't install node using homebrow so uninstalling and installing it again is the last solution for me.
Any help with this?

When on a Mac, use nvm to install node, and switch node versions.
Also can nicely reinstall packages when upgrading versions. nvm install 6 --reinstall-packages-from=5
This is better than homebrew, which I would not suggest for Node on a Mac.

Related

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?
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.
I fixed this issue this way:
yarn global add npm

Express not working with node 9.x

I have an Ubuntu box with node - v 9.5.0 and npm - 5.6.0 versions. I am trying to use expressjs (http://expressjs.com), but unable to run it. It works fine for node v 4.x.x.
$ express -h
module.js:557
throw err;
^
Error: Cannot find module 'commander'
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> (/usr/lib/nodejs/express-generator/bin/express:3:15)
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)
What is it that I am missing here?
Ubuntu's packages seem to be outdated.
Installing using apt-get node-express-generator gives this error.
Installing using npm i -g express-generator works fine.
Please try to follow the preceding steps.
Install the current version of NodeJS
Uninstall all modules with npm uninstall and rm -fr ~/.npm
Reinstall express-generator
Hope it helps.

kibana 6.0.1 stopped working after installing node.js and npm?

I am running Kibana 6.0.1 and everything was working fine until I have installed Node.js (version 8.9.3) and npm (5.6.0) on (im running Windows 10). the error im getting is:
module.js:471
throw err;
^
Error: Cannot find module 'lodash/internal/toPath'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\angel\kibana-6\src\utils\unset.js:12:15)
at Module._compile (module.js:570:32)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\angel\node_modules\babel-register\lib\node.js:152:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
I have no idea what happened. I tried to install lodash but that gave me errors as well.
Kibana 6.0 uses node version 6.11.5 ( Refer https://github.com/elastic/kibana/blob/6.0/.node-version)
Please try installing this node version and try running kibana again.
// Install node version 6.11.5
nvm install 6.11.5
// Use node version 6.11.5
nvm use 6.11.5
Did you do install the correct version of lodash for this kibana 6.0 as suggested here: https://github.com/elastic/kibana/blob/6.0/package.json?

Gulp error, cannot find module 'vinyl'

I have been struggling with getting flux/react to work properly and thought that my npm, node or gulp versions were to old.
So I updated everything to the latest version and now I get the following error when i run gulp in ALL my projects:
module.js:340
throw err;
^
Error: Cannot find module 'vinyl'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/gulp-util/index.js:2:9)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
I have:
Uninstalled node and gulp through npm.
Uninstalled npm.
Installed node and npm via https://nodejs.org/en/
Installed gulp through npm
And it's still not working..
Anyone have any ideas?
As #keithRousseau pointed out, when I reinstalled the packages I forgot to install them with the parameter -g to install them as global packages.
Reinstalled them with -g and now it works!

npm throws error "Cannot find module 'readable-stream'"

Just installed node.js in windows 8. When I enter node -v in command prompt it successfully gives the version number v4.1.2 but when I use any npm command I get following error
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\Vivek\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)
How to fix this?
I encountered the same error (Windows 10). Here's how I solved it:
Uninstall nodejs through the control panel.
Go to C:/Users/$username/AppData/Roaming (note that the AppData folder is hidden by default).
Scroll down to the npm and npm-cache folders and delete both of them.
Reinstall nodejs.
Give that a try, I hope it works out!
Did you install readable-stream module ?
Try npm install readable-stream
Please try:
npm install readable-stream
Same here.
I didnt solve this err not to uninstall nodejs.
But installed latest one.
https://nodejs.org/en/

Resources