var http = require("http");
http.createServer(function(request,response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.writeHead(" This is just a start.. Remember what u thought of it.");
reponse.end();
}).listen(8888);
这是我在名为server.js
的文件中的JS代码,我想通过Node.js执行,但是它给出了错误:
SyntaxError: Unexpected identifier
文件的路径server.js
位于D Drive中,与我安装Node.js的位置相同。我该怎么办?
答案 0 :(得分:4)
使用此代码:
var http = require("http");
http.createServer(function(request,response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write(" This is just a start.. Remember what u thought of it.");
response.end();
}).listen(8888);
将其保存在名为" server.js"的文件中。并运行:
node server.js
答案 1 :(得分:1)
我不知道你的问题是否是拼写错误,但你使用的是reponse
而不是response
:
var http = require("http");
http.createServer(function(request,response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.writeHead(" This is just a start.. Remember what u thought of it.");
reponse.end(); // <------
}).listen(8888);