Lately there has been a lot in Node.js. In this post I will install the dependencies of Node.js and then finally after installing I will run the "Hello World". Lets go.
Since I am using Red Hat Enterprise Linux Server release 6.5 on Amazon EC2 , hence the code and illustrations are applicable for RHEL / CentOS / Scientific Linux 6
I will install Nodejs along with Npm (Node Package Manager).
Node.js and npm are available from the Fedora Extra Packages for Enterprise Linux (EPEL) repository. If your instance does not have it then, first download and enable EPEL.
To check if you have EPEL, run
sudo yum repolist
if you don't see epel, follow Step 2, else follow Step 3
(At the time of posting, the latest version is 6.8.)
Step 2 (optional, in case you do not have EPEL)
sudo su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'
sudo yum install npm --enablerepo=epel
And that is it !
We are now ready with node with npm. Lets see what have we done so far.
To check the version of node type node -v in the command line.
To check the version of the npm , type npm -v in the command line.
Now, lets write our first node.js program
Open a terminal and do the following
node console.log ("Hello Node"); Hello Node undefined
and we have our Hello Node !
To quit the node prompt press ctrl + c two times on the terminal.
I hope this helps you in installing Nodejs on your RHEL / CentOS / Scientific Linux 6 box.