gpt4 book ai didi

javascript - 类型错误 : Cannot create property 'next' on number '8080'

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

我是 node.js 的新手,并尝试使用下面的代码创建一个示例 Web 服务器,但我收到了此错误。有人可以指出/解释出了什么问题吗?

req.next = next; ^

TypeError: Cannot create property 'next' on number '8080'

// Setup empty JS object to act as endpoint for all routes
projectData = {};

// Require Express to run server and routes
const express = require('express');
// Start up an instance of app
const app = express();
/* Middleware*/
//Here we are configuring express to use body-parser as middle-ware.
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// Cors for cross origin allowance
const cors = require('cors');
app.use(cors());
// Initialize the main project folder
app.use(express.static('Weather-Journal-App'));


// Setup Server
const port = 8080;
const server = app(port, listening)
function listening(){
console.log(`App server is up and running on localhost: port ${port}`);
};

最佳答案

我相信你想使用:

app.listen(port, listening)

而不是app(端口,监听)

关于javascript - 类型错误 : Cannot create property 'next' on number '8080' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60480559/

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