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).
Hi.
I first did the”From repository” method (from another website, but it was exactly like yours) and it worked.
node -v indicates v0.6.18
But since it was not the latest version, I decided to do the ‘from source” method (from this page)
It worked too, but I think the other version is still installed, because when I type ‘node -v’, it still shows v0.6.18
when I go to the directory in which I compiled node, and I type ‘./node -v’, it shows v0.8.15.
But how can I link the command “node” to the version that I just compiled ?
How can I remove the old version ?
Thx.
I guess you can remove the “node” from repository like any other package with yum.
Armetiz.
Je viens de voir que tu es français. Vu que le billet est en anglais, je ne m’étais pas posé la question …
Effectivement un ‘yum remove nodejs’ m’a débarassé de l’ancienne version.
Et j’ai refait un lien symbolique de /usr/bin/node vers ma version plus récente.
Merci.
Hello,
On my Centos6.4-x64 I try to recompile, but I get
[root@server node-v0.10.3-darwin-x64]# ./configure
-bash: ./configure: No such file or directory
so I get blocked [ to my level of knowledge ]
Can you please help out ?
Many thanks,
Radu
Hi @radu,
The ‘configure’ file is located inside the “node-*” folder that you just have downloaded.
Check twice 😉