Ok so I'm basically having the same problem as this. But the answers given there don't work for me. So let me re-explain my problem. First of all, here's my code:
Server-Side Javascript (app.js)
var io = require('socket.io');
...
var sio = io.listen(app);
Client-Side Javascript (client.js)
3: var socket = (s)io.connect('http://localhost:3000');
//the (s) represents testing with and without the s out of desperateness :)
Client-Side Template (Jade)
script(src='/socket.io/socket.io.js')
script(src='/javascripts/client.js')
So from what I've read it seems like socket.io should be handling putting the socket.io.js file there but I'm guessing that I have something configured wrong because it's not doing that. Anyways the errors I get with this are:
GET http://localhost:3000/socket.io/socket.io.js 404 (Not Found)
Uncaught ReferenceError: io is not defined - client.js line 3
After doing some research it seemed that I could change the jade file to link directly to a stable file. So by changing my code to this:
Client-Side Template (Jade)
script(src='http://cdn.socket.io/stable/socket.io.js')
script(src='/javascripts/client.js')
Then the error that I get from this is:
Uncaught TypeError: Object #<Object> has no method 'connect' - client.js line 3
I've been trying to figure this out for hours now. And it seems that I need to have socket.io-client so I made sure that it is installed. I dunno if this will but I am using Express.js as well and I will give you the layout of my files.
/project
app.js /node_modules package.json /public /routes /views
/project/node_modules
/connect /express /jade /jquery /socket.io /stylus
/project/node_modules/socket.io
/benchmarks index.js Makefile package.json restrict_jsonp.patch
History.md /lib /node_modules Readme.md
/project/node_modules/socket.io/node_modules
/policyfile /redis /socket.io-client
/project/public
/images /javascripts /jquery /stylesheets
/project/public/javascripts
client.js
Anyways, any help would be greatly appreciated! :)