Your First NodeJS App “Hello World”

nodejs logo

My Top 10 List: First NodeJS App “Hello World”

Below are the simplest possible steps to create your own first NodeJS app “Hello World”.

It is one of the most widely used programming language because of its asynchronous event driven JavaScript runtime built upon Chrome’s V8 JavaScript engine. It not just helps in building scalable network applications but also helps us to make it at ease – which makes it one of the “Human Friendly” development technology.

Before we start, asynchronous helps you handle multiple events by allowing you to create a separate thread for each event. This flexibility helps developer build parallel processing of multiple activities. Below are the steps to create your first app in Node JS:

Download & Install NodeJS on your platform (MacOS, Windows or Linux)

Open in your browser. The home page of the webpage gives you the direct download link. Just download and install it. Post installation, it provides you all the necessary tools to run a server on your own local machine.

NodeJS download page

Make your first directory for NodeJS using command prompt

mkdir myapp
cd myapp

Once you are done with the installation, its time for you to create your first directory for NodeJS app using above command. However, it is a universal command and almost all of the developers will be aware of it.

Initialize your first project by linking it to npm (node package manager)

NPM – Node Package Manager contains all node packages, it can be viewed as bundles of code like modules (similar to python modules – if you are familiar with it) which carries certain specific functions. Packages are pre-built features which makes it easier for developers to use.

The modules are blocks that carries out specific functions which can be linked together to achieve desired output. Finally, to initialize use the below command

npm init

Post execution, it creates a package.json file in your myapp folder. Basically, this will download npm packages to your project folder

Create server

Now, its time to create the server. Use the require directive to load the http module and then store the HTTP instance in a variable.

var http = require("http");

Now to create the server, use the created http instance and call http.createServer() as shown below

http.createServer(function (request, response) {
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain
   response.writeHead(200, {'Content-Type': 'text/plain'});
   // Send the response body as "Hello World"
   response.end('Hello World\n');

// Console will print the message
console.log('Server running at');

Place the above script along with the variable http which was initialized abvoe in a file, for eg: “main.js” and then execute the main.js to start the server as follows −

Below script in command prompt will confirm the successful creation of the server.

Server running at

Now, make a request on a browser to view the app

NodeJS server in browser

Thats Great…! You have your first HTTP server up and running which is responding to all the HTTP requests at port 8081.

Now that you have built your first App using NodeJS, here is a list of top 10 apps built on NodeJS

1. NodeJS – PayPal

2. NodeJS – Netflix

3. NodeJS – Uber

4. NodeJS – LinkedIn

5. NodeJS – Ebay

6. NodeJS – Walmart

7. NodeJS – Medium

8. NodeJS – NASA

9. NodeJS – Mozilla

10. NodeJS – Trello

Below is NodeJS best selling book on Amazon. In case if you are interested to have a look at it.

About NodeJS app

Above details provided is just a basic example on how to create your first NodeJS application. If you feel there is an edit possible for this blog then feel free to comment it to share your opinion.

Top 10 NodeJS Applications: More Information

If you are looking for a script of any of the above top 10 NodeJS applications then feel free to comment below along with your email ID. I will try my best to send the solution the very same day.

Related posts

11 thoughts on “Your First NodeJS App “Hello World”

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your next write ups thanks once again.

  2. I got this web page from my friend who told me concerning this web page and at the moment this time I am
    visiting this website and reading very informative posts
    at this place.

  3. You could definitely see your skills in the work you write.
    The arena hopes for even more passionate writers
    like you who are not afraid to say how they believe. At all times follow
    your heart.

  4. Good answer back in return of this query with solid arguments and telling everything concerning that.

  5. Marvelous, what a blog it is! This website gives helpful
    information to us, keep it up.

  6. This is a great tip particularly to those new to the blogosphere.

    Short but very precise info… Many thanks for sharing this one.
    A must read post!

  7. I would like to get across my admiration for your kindness supporting men who absolutely need help on the niche. Your personal commitment to passing the solution all-around had become astonishingly productive and have consistently permitted some individuals just like me to get to their dreams. Your entire invaluable facts denotes a great deal to me and much more to my office workers. Thank you; from everyone of us.

  8. I and my friends have been reading through the excellent ideas on your site and then suddenly came up with a horrible feeling I never expressed respect to the web site owner for them. These young men were definitely for this reason warmed to learn them and have now really been taking advantage of them. Many thanks for turning out to be so kind and also for pick out this form of great information most people are really eager to know about. My personal sincere apologies for not expressing gratitude to you earlier.

  9. Thanks so much for giving everyone such a marvellous opportunity to check tips from here. It is always very good plus full of a lot of fun for me and my office friends to visit the blog more than three times in a week to read through the newest guides you have. Not to mention, I’m so at all times contented concerning the striking methods you serve. Certain two points in this post are in fact the finest we have ever had.

  10. Greetings! Very helpful advice within this article!
    It is the little changes that produce the largest
    changes. Thanks a lot for sharing!

  11. I want to express thanks to this writer for rescuing me from this type of challenge. Right after checking through the search engines and coming across recommendations which were not powerful, I was thinking my entire life was well over. Living devoid of the solutions to the problems you have sorted out by means of this article is a serious case, as well as the kind that might have in a wrong way damaged my career if I hadn’t discovered your site. Your good capability and kindness in dealing with all things was priceless. I’m not sure what I would have done if I had not encountered such a solution like this. It’s possible to at this moment look forward to my future. Thanks very much for this specialized and amazing guide. I will not think twice to propose your site to any person who requires recommendations on this situation.

Leave a Comment