Error: Cannot find module 'socket.io'

you might have installed but not added to the dependencies in package.json Use below command to install socket.io module

npm install socket.io --save

Hope this will resolve your problem..


Thanks ajtrichards!

Just to add to the answer - in case you simple use

sudo npm install socket.io

The installation path will be

/home/.../.npm/socket.io

If you use sudo npm install -g socket.io

The installation path will be

/usr/local/lib/node_modules/socket.io

In first case, I tried adding the socket.io path in global path variable but it did not work.


Looks like you have installed socket.io in a different location to your current path. Either install globally like below:

npm install -g socket.io

Or reference the location you've installed to:

var io = require('../lib/socket.io');