This will start a simple server on port 3000.
Save to a file index.js
var http = require('http');
console.log("Server listening on port 3000");
http.createServer((req, res) => {
console.log("Got a request");
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Hello World!");
}).listen(3000);
Run with:
$ node index.js
Output:
Server listening on port 3000
