nodejs代码报错

学着写了一段代码var http = require("http");http.createServer(function (request, response) { response.writeHead(200, (✀Content-Type✀: ✀text/plain✀)); response.end(✀Hello World尀n✀);}).listen(8888);console.log(✀Server running at http://127.0.0.1:8888/✀);用终端执行时报错了F:尀learnnode>node server.jsF:尀learnnode尀server.js:12 response.writeHead(200,(✀Contet-Type✀: ✀text/plain✀)); ^SyntaxError: Unexpected token : at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10) at startup (node.js:139:18) at node.js:968:3F:尀learnnode>请问下是哪里出了问题呢?
2026年09月25日 15:10
有1个网友回答
网友(1):

把圆口号改成大括号试试
response.writeHead(200, {'Content-Type': 'text/plain'});