简体   繁体   English

node.js表达没有响应

[英]node.js express not responding

I was making a node.js web server on my laptop and it worked without problems. 我在笔记本电脑上制作了一个node.js Web服务器,它工作正常。 After moving it to my desktop it stopped working because the request was always timing out. 将其移到我的桌面后,它停止工作,因为请求始终超时。 After trying to get it to work I decided to try a new script but the request kept timing out. 在尝试使其正常运行之后,我决定尝试一个新脚本,但是请求一直超时。

This is what I tested 这是我测试的

const express = require('express')
const app = express()

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(3000, () => console.log('Example app listening on port 3000!'))

I have tried disabling my windows firewall and avast but it didn't do anything. 我曾尝试禁用Windows防火墙和avast,但它没有执行任何操作。 I also reinstalled node.js and still have this problem. 我还重新安装了node.js,但仍然遇到此问题。

So I thought that maybe I should restart my pc even if I didn't think it would help. 因此,我认为即使我认为这不会有所帮助,也应该重新启动计算机。 But restarting fixed the issue and now it works as it should. 但是重新启动可以解决问题,现在可以正常运行了。 Thanks to everyone for helping. 感谢大家的帮助。

Did you try to add "res.end()"; 您是否尝试添加“ res.end()”; after the "res.send('Hello World!')" ? 在“ res.send('Hello World!')”之后?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM