Node.js 找不到模块“可读流”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24010598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Node.js cannot find module 'readable-stream'
提问by Ronak Hindocha
I am new to node.js and stuck on the following. Any help will be appreciated:
我是 node.js 的新手,并坚持以下内容。任何帮助将不胜感激:
I am running node.js (0.10.28) on ubuntu (12.10). The code I am working on is:
我在 ubuntu (12.10) 上运行 node.js (0.10.28)。我正在处理的代码是:
"use strict";
var mysql = require('node-mysql'),
connection = mysql.createConnection({
host: "127.0.0.1",
user: "user",
password: "password",
database: "dbname"
});
if(connection) {
console.log("Query");
connection.query("select * from client",function(err,res) {
if(err)console.log(err);
console.log(res);
});
}
I get the following error
我收到以下错误
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/RonakNodeEmail/node_modules/node-mysql/lib/protocol/sequences/Query.js:7:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
回答by Jamie Hutber
I got this error for the a long while. Stupidly I hadn't installed gulp... In short this problem occurs when a package is missing.
很长一段时间我都遇到了这个错误。愚蠢的是我没有安装 gulp ......简而言之,当一个包丢失时会出现这个问题。
npm install gulp -g
I would suggest working out which task you are running and then install that.
我建议找出您正在运行的任务,然后安装它。
回答by Badjem79
In my case, (windows) after uninstalling nodejs, and before reinstalling it I had to delete the folder:
在我的情况下,(windows)卸载 nodejs 后,在重新安装它之前,我必须删除该文件夹:
C:\Program Files\nodejs\node_modules\npm
C:\Program Files\nodejs\node_modules\npm
and after reinstalling node it worked like a sharm
重新安装节点后,它就像一个 sharm
回答by user1452306
There were many reason for this issue: I have faced this issue because I had older version of node.js related files.
这个问题有很多原因:我遇到这个问题是因为我有旧版本的 node.js 相关文件。
- Un-install the node.js
- Go to your user folder like
C:\Users\<uname>and find all the node.js related files and delete everything. - Install node.js freshly
- 卸载 node.js
- 转到您的用户文件夹
C:\Users\<uname>,找到所有与 node.js 相关的文件并删除所有内容。 - 全新安装 node.js
It worked for me.
它对我有用。
回答by villy393
I was having this problem building a vue library. Deleting node_modulesand re-running npm isntalland then rebuilding my lib worked.
我在构建 vue 库时遇到了这个问题。删除node_modules并重新运行npm isntall然后重建我的库工作。
回答by ajay Sharavat
After grepping I found:
grepping后我发现:
$ cd /usr/lib/
$ ack-grep readable-stream
nodejs/sha/index.js
3:var Transform = require('stream').Transform || require('readable-stream').Transform
and change that line to:
并将该行更改为:
var Transform = require('stream').Transform // || require('readable-stream').Transform
and error goes out!
错误消失了!
-- System Information:
-- 系统信息:

