socket.io, io is not defined (JS Error)
I faced the same problem when using express. Even putting the server:port inside the script would not work.After the server started i would make socket listen to that port, that was mistake i guess.Changing it to below works fine
var app = express();
app.set('port', process.env.PORT || 3000);
var server = http.createServer(app);
var io = require('socket.io').listen(server);
server.listen(app.get('port'));
On Client side I just include the script
<script src="/socket.io/socket.io.js"></script>
put <script src="http://yournodeserver/socket.io/socket.io.js"></script>
into your code
Alternatively you can use the Socket.io CDN:
<script src="https://cdn.socket.io/socket.io-1.0.0.js"></script>