Saturday, 29 June 2013

An in-depth Node.js tutorial series - Installation

This is a very comprehensive tutorial series, that will be covering most aspects of node.js. Today, we will install node, and get it running on our Linux host. If you are a Windows user, there is an installer available, which makes the whole process ridiculously simple.

Here is how you go about setting node.js up on an Ubuntu host. I have tested this on versions 10.04LTS and 12.04LTS.

Step 1
The node.js binaries are available here. On Ubuntu, you can download, and install from the command line as follows,
cd ~
mkdir Node
cd Node
tar -xvzf node-v0.10.12-linux-x86.tar.gz
Step 2
At this point node.js is installed on your host. Here is how you can test it,
cd node-v0.10.12-linux-x86
cd bin
> console.log("Hello");
Step 3
We now add this to our environment so that we can call node from any directory. My installation path, up to the bin directory looks like this:
Yours will, of course, differ, so just go to the bin directory, and type pwd to get the full path.

Now, I enter the /usr/bin directory, and I create soft links to the node and npm commands as the super user. Remember, your path will not be same as mine, so can't use these commands directly.
sudo ln -s /home/jdepths/Node/node-v0.10.12-linux-x86/bin/node node
sudo ln -s /home/jdepths/Node/node-v0.10.12-linux-x86/bin/npm npm
This completes the setup, and you are now ready to use node.js on your host. Go to any directory and type,
node --version
You should see something like v0.10.12. This is the version of node.js you have installed. At the time of this writing, v0.10.12 is the latest version available.

No comments:

Post a Comment