我一直在尝试遵循一些 Node js 教程,但我似乎无法这样做,因为 response.writeHead 不在那里..
var http = require("http");
http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
我正在尝试执行上面的代码但我收到警告“未解析的函数或方法 writeHead()” - 我环顾四周但无法进一步了解,有人可以帮忙吗?
最佳答案
我相信您使用的是 IntelliJ IDEA,警告与 node.js 无关,而是与 IDE 本身有关。检查你的设置
IntelliJ IDEA -> 首选项 -> JavaScript -> 库
-> [确保选中“Node.js Globals”]
关于node.js - NodeJS response.writeHead 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33789502/