简体   繁体   English

Nodejs服务器创建未运行

[英]Nodejs Server Creation not running

iam very new to nodejs. 我对nodejs非常陌生。 I found difficult with this server creation program 我发现此服务器创建程序很困难

var http =  require("http");
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}

http.createServer(onRequest).listen();

You have to mention the port number to listen. 您必须提及要监听的端口号。

Your code has to have aport number in the listen. 您的代码必须在侦听中包含端口号。

http.createServer(onRequest).listen(8080);

The port number 8080 was already in use....So i used 端口号8080已经在使用中...所以我用了

another port number like 8083....It works... 另一个端口号,例如8083。

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

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