我刚刚安装了节点。我遵循了它的入门指南并运行文件。这是文件:
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(3000, "localhost", () => {
console.log(`Server running at http://${localhost}:${3000}/`);
});
在firefox上运行localhost:3000后,它说无法连接。