简体   繁体   中英

Nodejs Server Creation not running

iam very new to 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

another port number like 8083....It works...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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