"TypeError:res.sendStatus不是函数"为什么我会在一段时间后收到此错误?

Md.*_*ose 7 javascript node.js express

我已经使用npm安装了'express',我已经成功地在3000上收听了端口号.但过了一段时间我得到了以下错误,

TypeError:res.sendStatus不是函数

我们知道,res.sendStatus(404)与express有关.但是express明确定位.

这是app.js中的源代码

var express = require('express'),
app = express();

app.get('/', function(req, res){
  res.send('Hello Worlds');
});

app.use(function(req, res){
  res.sendStatus(404); 
});

var server = app.listen(3000, function() {
  var port = server.address().port;
 console.log('Express server listening on port %s', port);
});
Run Code Online (Sandbox Code Playgroud)

这是我的完整cmd输出,

> $ node app.js
Express server listening on port 3000
TypeError: res.sendStatus is not a function
    at Object.handle (I:\mongoUniversity\hello_world_templates\app.js:14:9)
    at next (I:\mongoUniversity\hello_world_templates\node_modules\connect\lib\proto.js:174:15)
    at pass (I:\mongoUniversity\hello_world_templates\node_modules\express\lib\router\index.js:110:24)
    at Router._dispatch (I:\mongoUniversity\hello_world_templates\node_modules\express\lib\router\index.js:173:5)
    at Object.router (I:\mongoUniversity\hello_world_templates\node_modules\express\lib\router\index.js:33:10)
    at next (I:\mongoUniversity\hello_world_templates\node_modules\connect\lib\proto.js:174:15)
    at Object.expressInit [as handle] (I:\mongoUniversity\hello_world_templates\node_modules\express\lib\middleware.js:30:5)
    at next (I:\mongoUniversity\hello_world_templates\node_modules\connect\lib\proto.js:174:15)
    at Object.query [as handle] (I:\mongoUniversity\hello_world_templates\node_modules\connect\lib\middleware\query.js:43:5)
    at next (I:\mongoUniversity\hello_world_templates\node_modules\connect\lib\proto.js:174:15)
    at Function.app.handle (I:\mongoUniversity\hello_world_templates\node_modules\connect\lib\proto.js:182:3)
    at Server.app (I:\mongoUniversity\hello_world_templates\node_modules\connect\lib\connect.js:67:37)
    at emitTwo (events.js:87:13)
    at Server.emit (events.js:172:7)
    at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:525:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
Run Code Online (Sandbox Code Playgroud)

我已经检查了类似的问题,他们告诉我们检查是否安装了'express',但我已经正确安装了它.那我在做错什么?

Pat*_*rts 7

使用express 4.x,因为只有新的express API支持res.sendStatus.