2016-05-21 17 views
7

Ben UÖM'yi kullanarak 'ifade' yüklemiş, başarıyla"TypeError: res.sendStatus bir işlev değil" neden bir süre sonra bu hatayı alıyorum?

TypeError: res.sendStatus is not a function

Bildiğimiz gibi, res.sendStatus(404) express.but ile ilgilidir, 3000 tarihinde ama şu hata var bir süre sonra dinleme bağlantı noktası numarası var ekspres açıkça yer almaktadır. İşte

> $ 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) 

Ben 'ifade' yüklenmişse onlar kontrol etmek anlattı benzer sorular, kontrol ettikten Burada

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); 
}); 

benim tam cmd çıkışı app.js kaynak kodu ya da değil, ama doğru şekilde kurdum. O zaman ne yapıyorum yanlış?

+1

Kullandığınız ifade sürümünü kontrol edin. Sadece '' x' 'res.sendStatus' kullanır. –

+0

Sabit !, Teşekkürler @PatrickRoberts "package.json" dosyasında tanımlı ekspres sürümünün 3.x olduğunu (şimdi güncellenmiş) buldum, ama ben de ekspres sürümde kontrol ettiğimde ekspres 4.13.4 versiyonunu da global olarak yükledim satır her zaman 4.x sürümü döndü, bu yüzden sürüm hakkında daha az endişeliydim. –

+0

Express'in tüm dünyada kurulması gerekmez, bu yüzden bunu yapmaktan kaçının. –

cevap

İlgili konular