cannot find on nodejs server running

cannot find on nodejs server running


clean install node ,express, on linux environment using npm. I try to sample from official source, I am getting error module not found on command line.

I work around few hours to solve this. but I didnt found any soutions.

Error :

    throw new Error("Cannot find module '" + request + "'");
Error: Cannot find module ''
    at Function._resolveFilename (module.js:337:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:359:17)
    at require (module.js:375:17)
    at Object.<anonymous> (/home/rajuk/Documents/nodeSamples/node_modules/
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:32)
    at Function._load (module.js:311:12)
    at Module.require (module.js:359:17) install result /usr/local/lib/node_modules/ 
├── base64id@0.1.0
├── policyfile@0.0.4
├── redis@0.7.3

here is my code(app.js)

var app = require('express')()
  , server = require('http').createServer(app)
  , io = require('').listen(server);


app.get('/', function (req, res) {
  res.sendfile(__dirname + '/index.html');

io.sockets.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {

and node_modules directory contains and express packages.

I am trying to run server like this

$ node app.js

how to resolve it?

Problem courtesy of: Konga Raju


Clone this git depositery :

And tell me if you still have an error.

Solution courtesy of: Yacine Rezgui


Leave a Reply

Your email address will not be published. Required fields are marked *