Node.js For Beginners: How to Install the Program?

Getting started with any new project is overwhelming, but most would agree that the stress level climbs up one or two notches when you’re dealing with code. Even if you’re pretty good with creating and solving different coding issues, there is always that thought in the back of your head: One little mistake could take me hours to find. While this is the unfortunate reality, most find that working with different coding programs does not need to be difficult if you really take the time to understand how it works and understand the big picture before diving into your own project. This mentality rings true when working with Node.js.

What Is Node.js?

Node.js, commonly referred to as Node, is a software system that uses JavaScript in order to write special Internet applications. It’s important that you have a fairly good understanding of JavaScript and how the system works before trying to get involved with Node. It’s also important to realize that while this is JavaScript, Node is different and you will need to start with the basics.

So what makes Node different? Node is essentially allows you to run JavaScript code outside of a browser. It is server-side JavaScript. It utilizes Google’s V8 JavaScript engine that Google Chrome uses, so when it comes to hosting you won’t be able to use many of the most popular web hosts, but instead should be using hosts that are V8 such as Cloudnode, DotCloud, or bejes.us.

Note-JS for Beginners

As far as the reputation of Node goes, it’s considered one of the best systems for a programmer to understand. As Brett McLaughlin of O’Reilly Radar says, “It’s the latest in a long line of ‘Are you cool enough to use me?’ programming languages.” Node is used by major corporations such as LinkedIn, Microsoft, and eBay.

How to Install Node.Js:

Installing Node is unfortunately different depending upon which operating system you are using. The installation should work well for Linux, Mac, and Solaris, but it’s a bit more complicated if you’re trying to use Windows. There are really two choices that you will have when it comes to installation:

  1. Building – You can build the code on your own. Again, this will depend upon the operating system you are using.
  2. Manual – There are pre-compiled codes that you can find from Google that allow you to manually install Node. You can usually find these codes quite easily on Google.

The installation process can be quite grueling, but it is unfortunately necessary to start really getting into the fun stuff. Python 2.6 or 2.7 as well as GNU make 3.81 or newer is required. Once you have the software ready to go, you will be walked through the installation process.

How to Create a “Hello World” File:

“Hello World” is the most basic type of file you can create (in most programming languages). If you can get this down, you’ll be ready to move onto more intermediate and advanced Node creation. Until then, creating a “Hello World” page is a great start.

Step 1:

is as easy as creating a file with a “.js” extension in whatever editor you wish. You need to type in the following code into the editor:

  1. var http = require(‘http’);
  2. var server = http.createServer(function(request, response){
  3.     response.writeHead(200, {
  4.         ‘Content-type’ : ‘text/plain’
  5.     });
  6.     response.end(‘hello world’);
  7. });
  8. // where the host in located
  9. server.listen(8080); //see the code below

This Node.js HTTP server that you just created will output a “Hello World” webpage for every request to port 8080. Remember, Node is all about creating requests.

Step 2:

involves writing a program that will actually respond to the Hello World program you just wrote. You can call this file “my_http.js” and use the following code:

  1. my_http.createServer(function(request,response){}).listen(8080);

Step 3:

is all about testing. You want to make sure that you’ve done everything correctly, so all you need to do is open a new browser tab and go to the URL of your local host (which should be port 8080 in this case). The URL looks like: http://localhost.8080/. You should then see a response that says “My_Http.”

What Comes After “Hello World” for Node.js?

The possibilities are truly endless when it comes to working with Node.js. Understanding JavaScript is your first hurdle with creating a “Hello World” file second. Once you have the basics down, you can begin writing more advanced code to help show you cool statistics or create cool features for your website.

Do you have any tips regarding Node.js? Have you found any tutorials that you have found particularly helpful? Let us know in the comments below!

About The Author

Amanda DiSilvestro

Amanda DiSilvestro gives small business and entrepreneurs SEO advice ranging from keyword density to recovering from Panda and Penguin updates. She writes for HigherVisibility, a nationally recognized SEO consulting firm that offers online marketing services to a wide range of companies across the country. Connect with Higher Visibility on Google+ and Twitter to learn more!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Select your Language please »