I am trying to start Nodejs using the Socket.io module. I installed the latest version of Nodejs and I installed socket.io from a command prompt that is open as an administrator (I'm on Windows 7) using the npm install socket.io command. The installation completes without any problems, but when I try to run the following test program:
var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); });
I get this error:
module.js:340 throw err; Error: Cannot find module 'socket.io' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.<anonymous> (C:\xampp\htdocks\HTML5Game\impact\app.js:1:72) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function .Module._load (module.js:312:12) at Module.runMain (module.js:487:10)
In my search I found some things about dependency issues and some incompatibility suggestions between socket.io and Nodejs version, but both talked about older versions of socket.io and Node Thanks.
Apalmer
source share