I've found numerous installation instructions for Node.js but they all seem so complicated -- I'm not a super sys admin but I can get around. I have yum on the system, but I didn't find any node.js packages, and I'm not sure how to compile code on the server or where to put it.
Note that this requires Python 2.6+ to use
./configure
above. You can modify the "configure" file to point topython2.7
in line 1 if necessary.To create an RPM package, you can use FPM:
Now make the
nodejs
package:Then install and check the version:
Source: https://github.com/jordansissel/fpm/wiki/PackageMakeInstall
If you have CentOS 6.x, and have enabled the EPEL repository, you can use yum to install node/npm:
After the installation is complete, check to make sure node is setup properly:
(Should return something like
v0.10.36
).If you want later versions of Node.js (e.g. 4.x, 5.x, etc.), you can use the Nodesource yum repository instead of EPEL.
The gist "Installing Node.js via package manager" does NOT contain instructions for installing nodejs on CentOS any more. Since Fedora 18, nodejs becomes part of the standard repo. I try "epel-fedora-nodejs" repo, and find it no longer update, leaving the version at the outdated 0.6.0.
The good news is that, we have nave, a Virtual Environments for Node, to help us.
https://github.com/isaacs/nave
Installing nodejs is dead easy now.
In the nave.sh file, you may have to change the local urls to the match with the latest dist structure of nodejs. For 0.11.0 I changed the nave.sh to have the following URL
"http://nodejs.org/dist/v$version/node-v$version-linux-x64.tar.gz"
For CentOS
[Edit] Thank you David for pointing out in the comments below that the nodejs.tchol.org site is now pointing to a spam site (sic!).. So this answer doesn't work anymore, don't use it!
I can confirm that the method Chris explained in his solution does work in CentOS 5.4 (i've done it a minute ago :))
PS: of course you must be root (or use sudo) in order to install that..
Besides installing from source (which is always an option) maybe there is still an alternative: here I read that "node.js has been accepted into Fedora Rawhide as of December 2012 and will be available in Fedora 18.", so maybe it will eventually get into the standard CentOS repositories
I'll have a look at this..
As noted above, "tchol.org" is gone, leaving CentOS folks looking at either abandoning use of a package manager, or switching to another OS. I made a pact with myself against every doing the former (again) on all but experimental / dev boxes.
Fortunately, there are rpms still available at: http://patches.fedorapeople.org/oldnode/stable/el6/x86_64/
Just ignore the rpm for the repo-installer, which directs yum to the defunct site. That should buy us a little time, unless / until they become too obsolete.
I'll keep my eyes open for newer repos, and post back if I find them.
This worked for me on CentOS 5.7:
The answers above are outdated
AS ROOT
and you are done.
verify your install with
There's one more approach I haven't seen listed in any of the other answers, and that is to use the binary distributions for Linux which have been published since 0.8.6
Here's the script I use:
Or, if you want a specific version (e.g. to stay on the 0.8 series):
And for me on CentOS 6.3, I had to add the following links so that node and npm commands worked from either regular user or from sudo. Might not be needed depending on your version.
Frankly, the situation for node.js on CentOS/RHEL is rather bad, as none of the repos include node.js (see related question here). This answer has the same disadvantages as previously mentioned for compiling from source.
Run as root on RHEL, CentOS or Fedora, for Node.js v4 LTS Argon:
Alternatively for Node.js v5:
Alternatively for Node.js 0.10:
Then install, as root:
source: https://nodejs.org/en/download/package-manager/