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!

Community
  • 1
  • 1
6324
  • 4,678
  • 8
  • 34
  • 63
  • `npm` appears to require [readable-stream](https://github.com/npm/npm/blob/db9cde008ce855bdac801bb6649cbfb5bb7911ac/package.json#L85). 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) – dvlsg Apr 07 '16 at 16:36
  • @dvlsg Yes, I have it... – 6324 Apr 07 '16 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. – dvlsg Apr 07 '16 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. :( – 6324 Apr 07 '16 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. – dvlsg Apr 07 '16 at 16:49
  • @dvlsg I think your explanation makes sense. If possible, can you post an answer about this so that I can accept that as I don't want to accept my own answer. Thanks! – 6324 Apr 07 '16 at 16:52
  • I *can*, but even I'm not convinced it's the actual answer, haha. Hard to say, since it's fixed. Glad it's working, though. – dvlsg Apr 07 '16 at 17:47

4 Answers4

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.

dvlsg
  • 5,378
  • 2
  • 29
  • 34
  • 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 – tyrion Sep 19 '16 at 10:29
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.

6324
  • 4,678
  • 8
  • 34
  • 63
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.

Bubbles
  • 3,795
  • 1
  • 24
  • 25
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.

knarf
  • 702
  • 1
  • 9
  • 16