15

I am new to node.js and stuck on the following. Any help will be appreciated:

I am running node.js (0.10.28) on ubuntu (12.10). The code I am working on is:

"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)
2

5 Answers 5

16

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.

npm install gulp -g

I would suggest working out which task you are running and then install that.

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

2 Comments

Solved my problem - 10x!
Had same problem, I personally needed to reinstall node and deleted node_modules folder. npm install again and it's working fine now.
8

In my case, (windows) after uninstalling nodejs, and before reinstalling it I had to delete the folder:

C:\Program Files\nodejs\node_modules\npm

and after reinstalling node it worked like a sharm

Comments

5

There were many reason for this issue: I have faced this issue because I had older version of node.js related files.

  1. Un-install the node.js
  2. Go to your user folder like C:\Users\<uname> and find all the node.js related files and delete everything.
  3. Install node.js freshly

It worked for me.

1 Comment

I had also to delete the C:\Program Files\nodejs folder manually after uninstalling.
1

I was having this problem building a vue library. Deleting node_modules and re-running npm isntall and then rebuilding my lib worked.

1 Comment

This seamed to be the easiest solution so I tried it first and it worked for me!
0

After grepping I found:

  $ 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:

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.