I am trying to run this example (http://maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/) but I'm getting this error:
module.js:340
throw err;
^
Error: Cannot find module 'socket.io/node_modules/redis'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/felipemoran/Desktop/django-realtime-tutorial-master/nodejs/chat.js:7:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
What I did so far was:
redis-server
) - okpython manage.py runserver
, while in the propper folder) - okThe next step would be, on a third terminal window, run the command node chat.js
, while in the folder nodejs folder from the example files, but I'm getting this error.
I'm on Mac OS X Maverics, I installed node.js from the official mac installer and I installed socket.io using the npm command.
I also tried running rpm install socket.io -g
, rpm install -g socket.io
, those two with sudo
and runing these commands from the nodejs folder but still no success.
Thanks!
Running npm install socket.io
installs the latest version from npm which is now 1.1.0
. Your tutorial uses version 0.9
and a lot changed from that to 1.0
, including how to use the Redis adapter. Since the tutorial does not use a package.json to manage the dependencies you ended up with wrong version.
You can either upgrade your server code to work with latest socket.io
(for which you need to install socket.io-redis) or check the latest version from the 0.9
branch by running npm view socket.io versions
and then install npm install socket.io@0.9.17
.
And please remove the global installations, they will cause you gray hair later (npm uninstall -g socket.io
).