[~]# 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 [email protected] No repository field.
npm WARN package.json [email protected] 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. It consists of: a Node. js server: Source | API. a Javascript client library for the browser (which can be also run from Node.
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');
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.
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..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With