app.listen()返回
http.Server。您应该
close()在该实例而不是
app实例上调用。
例如
app.get( '/auth/github/callback', passport.authenticate('github', { failureRedirect: '/login' }), function(req, res) { res.redirect('/'); setTimeout(function () { server.close(); // ^^^^^^^^^^^ }, 3000) });var server = app.listen('http://localhost:5000/');您可以检查源:
/node_modules/express/lib/application.js



