简体   繁体   中英

npm --> Err: Cannot find module 'readable-stream'

I have installed node js on my windows 10 machine, and the version is v4.4.2 but when I try to run npm install or even check npm version it throwing the following error. Any help would be greatly appreciated

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)

Also, after reading other solutions to this problem, npm install gulp -g, npm install 'readable-stream' or any other suggestion I read and tried did not work. It appears any command I try with npm throws the error below.

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)

I have also tried uninstalling node and reinstalling and same issue persists.

I figured it out, when I uninstalld I did not delete all the files. There were the node/npm files in my C: directory and failed to realize there were a bunch of npm module files in my / directory. So after uninstalling and deleting all related files I reinstalled node/npm and it is now working.

After all the checks its clear you need to uninstall and re-install node:

sudo npm cache clean -f
sudo npm install -g n

sudo n stable // for stable version
sudo n 0.12.7 // for specific version like v0.12.7

// check the node version after install
node -v

如果您在Windows上,请确保在卸载节点后%appdata%或C:\\ Users \\ admin \\ AppData \\ Roaming并删除以前安装在此处创建的所有npm文件夹。

git clone https://github.com/nodejs/readable-stream到全局node_modules文件夹

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM