Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js cannot find module 'readable-stream'

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)
like image 501
Ronak Hindocha Avatar asked Jun 03 '14 08:06

Ronak Hindocha


1 Answers

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

like image 162
Badjem79 Avatar answered Oct 01 '22 03:10

Badjem79