gpt4 book ai didi

node.js - Express.js : Object # has no method 'call'

转载 作者:太空宇宙 更新时间:2023-11-03 23:11:16 25 4
gpt4 key购买 nike

安装 Express.js 后,我在 Node 上写了这个:

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

app.configure(function(){
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(express.router);
});
app.get('/', function(req, res){
res.send('hola mundo');
});

app.listen(3020);
console.log('Hola Mundo');

当我启动应用程序时,我可以看到消息“Hola Mundo”,但是当我发出请愿书时,我收到了以下消息:

TypeError: Object #<IncomingMessage> has no method 'call'
at Object.router [as handle] (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/middleware/router.js:96:6)
at next (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/http.js:203:15)
at Object.bodyParser [as handle] (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:88:61)
at next (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/http.js:203:15)
at Object.methodOverride [as handle] (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:35:5)
at next (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/http.js:203:15)
at Object.handle (/home/alumno/Escritorio/nodejs/node_modules/express/lib/http.js:84:5)
at next (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/http.js:203:15)
at HTTPServer.handle (/home/alumno/Escritorio/nodejs/node_modules/express/node_modules/connect/lib/http.js:216:3)
at HTTPServer.emit (events.js:70:17)

感谢您的阅读

最佳答案

删除app.use(express.router)并且它可以正常工作。

关于node.js - Express.js : Object #<IncomingMessage> has no method 'call' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8959181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com