I was having lots of difficulties to install node.js / npm on a server running CentOS 5. The node.js documentation mentions that we should be adding the EPEL repository and then using “yum install npm” to install it. However, no matter how much I tried, this package seems unavailable on CentOS 5. Compiling from source was a solution but I really did not want to install all the development tools on that machine that is essentially just a testing server. All I needed node.js for was to run tests from the mocha test framework.
After much research I finally found an answer on serverfault (a branch of StackOverflow). It suggests to use nave, a virtual environment for node that will install npm and node.js just for the local user. Turns out this is exactly what I wanted since it would simplify the migration if I need to move my testing environment to another server.
Commands in the console:
wget https://raw.github.com/isaacs/nave/master/nave.sh
chmod +x nave.sh
./nave.sh install stable
./nave.sh use stable
(You could replace stable with a specific node version number)
And that’s all! node and npm are available from this specific user, no need to compile node from source to use it from CentOS.