I am trying to build NodeJS/Express/SocketIO application.
Imports:
var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)...
Configuration:
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
In my Jade template:
script(type='text/javascript', href='/socket.io/socket.io.js')
But ‘/socket.io/socket.io.js’ is not available when I am trying to reach it on
http://localhost:3000/socket.io/socket.io.js
As it says:
Cannot GET /socket.io/socket.io.js
How do I serve socket.io.js from the installed module?
Thanks
You need to copy the client code from an inner Socket.io directory to your public directory. In Socket 0.9, the path to the distributable files is
node_modules/socket.io/node_modules/socket.io-client/dist.