我正在尝试构建 NodeJS/Express/SocketIO 应用程序。
进口:
var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)...
配置:
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')));
});
在我的 Jade 模板中:
script(type='text/javascript', href='/socket.io/socket.io.js')
但是当我尝试访问它时,'/socket.io/socket.io.js' 不可用
http://localhost:3000/socket.io/socket.io.js
正如它所说:
无法获取 /socket.io/socket.io.js
如何从已安装的模块中提供 socket.io.js?
谢谢