Getting Started With Node

Node.js, the V8 (Chrome’s JavaScript runtime) based platform for building fast and scalable network applications,  is gaining substantial traction among developers and entering the application stack of many silicon valley companies. Like every new technology or piece of software there is enough FUD (Fear, Uncertainty, and Doubt) around Node, so I am going to write a few blog posts and help you learn Node by example.

In this post, I will simply help you get set-up so you can start playing with Node. The best and most reliable way to get Node installed on your machine is to build it from source. On Linux, Unix, and Mac OSX, you can start out by getting Node source code from its repository like so:

git clone https://github.com/joyent/node.git

This assumes that you have a git client installed for your *nix flavor and you are familiar with the essential notions of git, like cloning a repository. If you are completely new to git, then you may want to quickly read and learn about git first. A good freely available resource on git is the book titled: Pro Git — http://git-scm.com/book/.

Now that you have the Node source cloned on your machine, change to the source directory and inspect the available tags in the repository as follows:

git tag -l

A whole lot of tags will be listed in response to this git command. Some of the latest ones are follows:

...
v0.7.5
v0.7.6
v0.7.7
v0.7.8
v0.7.9
v0.8.0
v0.8.1
works

The current master branch of the Node code is v0.9.x but unfortunatley that version seems to have problems working with NPM (Node Package Manager), a very important companion of Node. Therefore, you should checkout v0.8.1 before you build the source. To checkout the v0.8.1 tag, use the following command:

git checkout v0.8.1

From here onwards, its the usual configure, make, and make install trio. Build Node as follows:

./configure
make
sudo make install

That’s it! Node and NPM are both installed.

To verify, open up a terminal and run

node -v

If you see v0.8.1 in response then you are all set.

Additionally, verify that npm is installed by running

npm -v

You should see 1.1.33.

Now that node is installed, you are ready to play with node. In my next post, we will get started with a simple example.

Leave a Reply