nodejs-light

Install NodeJS on CentOS

Posted on 27/07/2012 · Posted in Linux

NodeJS isn’t available neither on centos base repositories nor on EPEL.
To install NodeJS, you can do it from a specific repository or you can compile it.

From repository

To install NodeJS from repository on a RHEL based distribution, including our CentOS, just do :

1
2
3
4
curl -o "nodejs.rpm" http://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm
yum localinstall --nogpgcheck nodejs.rpm
yum install nodejs-compat-symlinks npm
rm nodejs.rpm
1
2
node -v
#v0.6.18

From source

To compile NodeJS from source on your CentOS, you have to install missing dependancies : gcc-c++, python and libssl-dev

1
2
3
4
yum install gcc-c++ python libssl-dev
curl -o "node.tar.gz" "http://nodejs.org/dist/node-latest.tar.gz"
tar -xzvf node.tar.gz && cd node-v*
./configure && make install
1
2
node -v
#v0.8.4

Play with a simple “Hello world”

Just launch node in interactive mode.

1
node -i

Type a Javascript command.

1
2
3
4
> console.log ("Hello World");
Hello world
undefined
>

About version

As you can see, the repository provides an old version of NodeJS (0.6.14) compared to the latest released (0.8.4).