Home > DeveloperSection > Beginner > Hello World in Node.js

Hello World in Node.js

Node.JS Node JS 
0 Comment(s)
 2313  View(s)
Rate this:

Hello World in Node.js

In this article, we describe the example of hello world in node.js.

If you want to learn how to install and setup node.js first, then you can read my previous article using below link:


We open the command prompt with administrator and change the location where you want to keep your js file as like this:


Hello World in Node.js


Let we go to create a simple program for Hello world in node.js. Here, where we want to store our file we create a test.js file and select through command prompt but here we select c:\node folder and code into test.js file:

var http = require('http');

http.createServer(function (req, res) {

    res.writeHead(200, {'Content-Type': 'text/plain'});

    res.end('Hello World\n');

}).listen(1337, "");

console.log('Server running at'); 

To run this program command prompt type the node filename.js

Hello World in Node.js

And run on the browser:

Hello World in Node.js

The output of the test.js file by node.js. I hope that this article is helpful for you.


Don't want to miss updates? Please click the below button!

Follow MindStick