I've followed the exact same steps which have always previously worked for me, create application through express, place the module dependencies in the node_modules folder. It appears that the socket.io client-side javascript file isn't being found.
(I've looked at other peoples fixes, which is to include the JavaScript file in a script tab. I have not had to do this for my previous node + socket.io projects).
JavaScript on client:
var socket = io.connect('http://localhost');
JavaScript on server:
var io = require('socket.io').listen(app);
node_modules folder:
socket.io, which has an internal node_modules folder containing socket.io-client
Error Message:
Uncaught ReferenceError: io is not defined
(anonymous function)
When I include the socket.io client manually:
http://cdn.socket.io/stable/socket.io.js
I get a different error which is:
Uncaught TypeError: Object #<Object> has no method 'connect'
(anonymous function)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…