Node JS Hello World Program

1 Displaying Hello world in Console

filename : helloworld.js

console.log("Hello World");

Run the program

> node helloworld.js 
Hello World

 

2 Displaying Hello world in Browser

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello World!');
}).listen(8080);
> node helloworld.js 
Hello World
Post a Comment (0)
Previous Post Next Post