Node.js Express 3不提供socket.io.js

我试图按照这里的说明

http://socket.io/#how-to-use

不过,我似乎太愚蠢了,为什么我不能在客户端引用socket.io.jss。 我读过类似的post,但他们似乎不正确: NodeJS Express不提供'/socket.io/socket.io.js'

这里是完整的应用程序列表:

var application_root = __dirname, express = require('express'), //Web framework path = require('path'), //Utilities for dealing with file paths pg = require('pg'); //Postgres integration //Create server var app = express(); // Configure server app.configure(function () { //parses request body and populates request.body app.use(express.bodyParser()); //checks request.body for HTTP method overrides app.use(express.methodOverride()); //perform route lookup based on url and HTTP method app.use(app.router); //Where to serve static content app.use(express.static(path.join(application_root, 'public'))); //Show all errors in development app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); }); //Start server var port = 4711; app.listen(port, function () { console.log('Express server listening on port %d in %s mode', port, app.settings.env); }); //Start socket.io var server = require('http').createServer(app), io = require('socket.io').listen(server); 

现在,如果我试图引用客户端JS,我得到一个404。

 <script src="/socket.io/socket.io.js"></script> 

任何人都知道Express 3为什么不允许socket.io为其客户端lib服务?

我在这里find了答案

Socket.io不在/socket.io/socket.io.js中提供

请阅读http://expressjs.com/api.html#app.listen ,注意app.listen是如何定义的。

简而言之:用server.listenreplaceapp.listen。