使用连接时未定义不是函数

Undefined is not a function when using connect

我正在尝试设置一个简单的 HTTP 服务器,并在节点 REPL 上进行连接。我尝试了以下,

var connect = require('connect');
var http = require('http');

var app = connect()
  .use(connect.favicon())
  .use(connect.logger())
  .use(function(req,res) {
    res.end('Hello World\n');
});

但是我得到以下错误,

TypeError: undefined is not a function
    at repl:1:33
    at REPLServer.defaultEval (repl.js:132:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)
    at REPLServer.Interface._line (readline.js:553:8)
    at REPLServer.Interface._ttyWrite (readline.js:830:14)
    at ReadStream.onkeypress (readline.js:109:10)

我已经看过这个 question and answer 但它似乎没有帮助。我已经确保 connect 安装在我的 node_modules 目录中。

我做错了什么?

我知道为什么它不起作用。由于我使用的是 3.3.5 版本的 connect,它们不再提供某些中间件。它们已被删除,您必须手动寻找它们。根据他们GitHubreadme,

Some middleware previously included with Connect are no longer supported by the Connect/Express team, are replaced by an alternative module, or should be superseded by a better module.