May 10, 2021 Node.js
The first example of a server starts with Hello World:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
Copy the code into
example.js
file and execute it using the node program:
> node example.js
Server running at http://127.0.0.1:8124/
In this Node .js examples in the official documentation can be performed using the above methods.