【发布时间】:2020-06-26 21:08:51
【问题描述】:
我正在尝试连接到 node.js 中的 HTTP 服务器。 我花了一整天的时间在网上搜索以解决我的问题,但不幸的是,它没有用。
这是我参考官方 Node.js documentation 编写的一个简单代码。
Index.js
const http = require('http');
const requestListener = function (req, res) {
res.writeHead(200);
res.end('Hello, World!');
}
const server = http.createServer(requestListener);
server.listen(8080);
我在 CMD 终端中运行的代码
curl localhost:8080
我知道这个问题已经在堆栈溢出中被问了数千次,但没有一个能解决我的问题。谁能帮帮我?
【问题讨论】:
-
不是反对者,但问题很明显
-
更改了我的编辑@GuerricP.. :) 但问题还是一样..
-
请添加你的nodejs日志
-
请添加你的nodejs日志和
netstat -a -b的输出。你应该看到类似TCP 0.0.0.0:8080 DESKTOP-MOD2A4T:0 LISTENING [node.exe] -
你好@GuerricP 这是我的 netstat 截图。 imgur.com/a/MbtGz73
标签: javascript node.js express cmd localhost