[~]# node node.js
Error: Cannot find module 'socket.io'
[~]# node -v
v0.10.10
socket.io installed:
npm install socket.io
npm WARN package.json policyfile@0.0.4 No repository field.
npm WARN package.json policyfile@0.0.4 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
Thanks ajtrichards!
Just to add to the answer - in case you simple use
The installation path will be
If you use sudo npm install -g socket.io
The installation path will be
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:
I had the same issue with version 0.12.0 on Windows. I tried npm install -g socket.io but that didn't change anything. Also tried npm cache clean also no change, but after npm update npm -g, things got well.
This almost happens than you try to get socket.io in you html files like :
where you have:
It will not find socket.io because you did not started module in you application file wich contain the server like
You must include following lines after started your server in server.js :
Hope, will save time.
I think that you have executed the command
npm install socket.io
in a different location and your files are in different directory.. So either run the command in the same directory which have your files or either mention the path where you have currently installed socket.io in your PATH variable.