3

I installed nodejs and am trying to use npm on my Windows machine. I downloaded all the files from nodejs website. I tried to install the latest 4.4.2 version or 5.10.1 version, but I always got error Cannot find module 'readable-stream' when I tried to run commands using npm.

C:\Users\Ealon>node -v                                                             
v5.10.1                                                                             

C:\Users\Ealon>npm -v                                                              
module.js:341                                                                       
    throw err;                                                                      
    ^                                                                                                                                                                   
Error: Cannot find module 'readable-stream'                                         
    at Function.Module._resolveFilename (module.js:339:15)                          
    at Function.Module._load (module.js:290:25)                                     
    at Module.require (module.js:367:17)                                            
    at require (internal/module.js:16:19)                                           
    at Object.<anonymous> (C:\Users\Ealon\AppData\Roaming\npm\node_modules\npm\node
modules\npmlog\node_modules\are-we-there-yet\index.js:2:14)                         
    at Module._compile (module.js:413:34)                                           
    at Object.Module._extensions..js (module.js:422:10)                             
    at Module.load (module.js:357:32)                                               
    at Function.Module._load (module.js:314:12)                                     
    at Module.require (module.js:367:17)                                            

I tried to reinstall it again and again, still could not fix this problem. And the answers in another similar question do not help because I always got error when I tried to run any command using npm. Any help is appreciated. Thanks!

7
  • npm appears to require readable-stream. Do you have a readable-stream folder in your npm folder? (probably located at C:\Program Files\nodejs\node_modules\npm\node_modules, or a path similar) Commented Apr 7, 2016 at 16:36
  • @dvlsg Yes, I have it... Commented Apr 7, 2016 at 16:37
  • That is very odd. Good to rule that out, at least, though. Do you have any previous versions of npm installed? Possibly globally? You can type where npm from the command line to figure out if you have any additional installs / references in your path. I can see that its referencing %appdata%\npm in one of the errors, which I believe is where global installs go. Commented Apr 7, 2016 at 16:42
  • @dvlsg Thanks for your help. I somehow fixed this issue by upgrading npm in Intellij IDEA. But I still don't know why this issue happened. :( Commented Apr 7, 2016 at 16:45
  • I still feel like it was a weird global install. It looks like the are-we-there-yet module inside of a global npm install also needed a reference to readable-stream, so it's possible that that reference was missing. Hard to say. I'd be tempted to wipe out any install of npm in %appdata%, if there's still one there. Commented Apr 7, 2016 at 16:49

4 Answers 4

5

Judging from the line C:\Users\Ealon\AppData\Roaming\npm\node_modules\npm\node modules\npmlog\node_modules\are-we-there-yet\index.js:2:14 in the stack trace, I believe that you had a global installation of npm which internally had a dependency on are-we-there-yet, which I confirmed has a dependency on readable-stream.

The global installation of npm appears to have been borked, and are-we-there-yet couldn't resolve access to the readable-stream module for some reason (bad install?).

This wasn't getting fixed by re-installing node, which by default installs npm into program files (path similar to C:\Program Files\nodejs\node_modules\npm). I think the global version was getting run, but the version inside program files should be getting run, so wiping out the global installation of npm should hopefully resolve the issue.

Sign up to request clarification or add additional context in comments.

1 Comment

I installed latest node and landed into exactly same problem and got it working by using exactly same solution - wipe the global installation of npm. Thx
0

I somehow fixed this issue by upgrading npm in Intellij IDEA.

enter image description here

But I still want an expnalation why that problem in my question happened. I will not mark this as the answer.

Comments

0

No need to uninstall node js. When I tried to update my node version, I got this issue & resolved the the same by following below step -

Go to control panel --> uninstall Programs --> select node.js

and click repair.

Comments

0

Had this issue on a Mac. I cloned a project multiple times to handle different branches in parallel. Only one of my cloned repos started having this same issue when I ran npm start. I deleted the repo, cloned it again and nom was running fine again in that repo. Doesn't sound like a global issue to me. No idea what went wrong.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.