Starting with Node.js.

Published on Jun 11, 2010

Installing node.js

First, you need a supported OS, like Linux, Mac or Solaris. I will be doing the install on Ubuntu.
Go to the node.js download page download the Gzipped file and extract in a folder of your choice in your disk.
Open a terminal and go to the folder where you extracted the downloaded files.
Type ./configure, if you don’t have a c++ compiler you will see an error.

Compiling with g++

I choose to go with the g++ one, so I typed:

Running ./configure once again and everything should go with no problems.
Now type “make” and once that is finished

To verify that everything has been installed correctly type “node” in the command, you should have the Repl.
h3. Writing your first program.

Once in the shell you can type .help to see a list of some of the commands available.

Node.js repl

As with any Repl you can use it to play with and explore the different features or to write little one off scripts.
Let’s try a to write a little webserver (code taken from the node.js website).

A node web server
A node web server in the console.

Now when we visit “http://127.0.0.1:8124″ this is what we see.

node web server hello world.