Introduction to Node.js and Its Installation on Windows

We are all hearing about Node.js these days, but what exactly is node.js and why is it becoming so popular so quickly?

According the nodejs.org, "nodejs is a platform built on Chrome's JavaScript Runtime". In other words the code you write for the server will execute in a very similar manner in the browser. You can easily carry the JavaScript techniques you have learned elsewhere. It is fast, event-driven and lightweight but the biggest advantage of using the node.js is the asynchronous programming.

Asynchronous Programming

Every function in node.js is asynchronous which means that everything that would normally block the thread is instead executed in the background, in other words it continues running in the background and the flow of control moves to the next line and executes them; the moment the operation is completed it executes a callback that will then be executed. For example  if you are reading a file on the file system then you need to specify a callback function that is executed when the read operation has completed.

Installing Node.js on your Windows OS

First you need a Window OS that is at least Windows Vista, then download the MSI from http://nodejs.org/download/. At the time of writing this article the current verion is 0.10.15 but I will be using the 0.8.12 for these tutorials. It does make much difference since the previous version may/may not be compatible with each other since we don't have a major version coming up until now so its evolving very rapidly.

image1.gif

image2.gif

Download the Windows Installer and run the setup; click on "Next" and choose the default location to install to.

image3.gif

Ensure that you select both, the Node.js runtime the "Add to path" option here and install it.

To check your node install, search for the node.js command prompt in your programs and run it.

Type "node -v" and press Enter and you will see that node is installed and its correct version.

image4.gif

So you are done with the node installation. We can also install node on Azure; to learn more about that go here by Dhananjay Kumar.

Next we will try to write a "hello world" program in node.js.

Next Recommended Readings