• Tweet

If you are into web development, you probably have subscribed to the recent buzz going on Node.js. Today, we shall install node.js on your windows machine and get you started with node.js. But before we begin, first let’s see what is Node.js.

Node’s goal is to provide an easy way to build scalable network programs. In the “hello world” web server example above, many client connections can be handled concurrently. Node tells the operating system (through epoll, kqueue, /dev/poll, or select) that it should be notified when a new connection is made, and then it goes to sleep. If someone new connects, then it executes the callback. Each connection is only a small heap allocation.

In short, node is an application framework that helps you scale your application by using core OS task queuing facilities to achieve concurrent processing. From the excerpt above, you can probably figure out that node is heavily geared towards the *Nix system structure. However, in recent times, a windows port has been seen on the website.

So, let’s get started. First download the windows version of node.js from it’s website. For now, the latest version is: http://nodejs.org/dist/v0.5.8/node.exe.

After downloading, copy the node.exe to your system path. I would suggest creating “C:node” and then putting node.exe into that folder. Then adding “C:node” to the PATH variable from system properties.

Now that node.exe is on our system path, we are indeed ready to start building node apps. Let’s take this sample code:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Worldn');
}).listen(1337, "");
console.log('Server running at');

Save the content to “test.js”. Now from the CMD, type:

node.exe test.js

You have just setup and get node.js running on your Windows. Feel free to explore node and have fun!