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.
-
Thanks for the great answers everyone. I do believe you can yum install both nodejs and npm now! awesome – qodeninja Aug 14 '12 at 20:56
-
https://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/nodejs.html – Yolo Perdiem Dec 04 '13 at 14:39
-
...with EPEL (install instructions if you don't already have the repo: http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x). – geerlingguy Jan 02 '14 at 04:23
-
I don't think the EPEL stuff works anymore -- or doesn't work in Centos 7. – jcollum Jan 09 '16 at 20:13
20 Answers
su -
yum install gcc-c++ openssl-devel
cd /usr/local/src
wget http://nodejs.org/dist/node-latest.tar.gz
tar zxvf node-latest.tar.gz
(cd into extracted folder: ex "cd node-v0.10.3")
./configure
make
make install
Note that this requires Python 2.6+ to use ./configure
above. You can modify the "configure" file to point to python2.7
in line 1 if necessary.
To create an RPM package, you can use FPM:
# wget http://nodejs.org/dist/node-latest.tar.gz
# tar zxvf node-latest.tar.gz
(cd into extracted folder: ex "cd node-v0.10.3")
# ./configure --prefix=/usr/
# make
# mkdir /tmp/nodejs
# make install DESTDIR=/tmp/nodejs/
# tree -L 3 /tmp/nodejs/
/tmp/nodejs/
└── usr
├── bin
│ ├── node
│ ├── node-waf
│ └── npm -> ../lib/node_modules/npm/bin/npm-cli.js
├── include
│ └── node
├── lib
│ ├── dtrace
│ ├── node
│ └── node_modules
└── share
└── man
Now make the nodejs
package:
# fpm -s dir -t rpm -n nodejs -v 0.8.18 -C /tmp/nodejs/ usr/bin usr/lib
Then install and check the version:
# rpm -ivh nodejs-0.8.18-1.x86_64.rpm
Preparing... ########################################### [100%]
1:nodejs ########################################### [100%]
# /usr/bin/node --version
v0.8.18
Source: https://github.com/jordansissel/fpm/wiki/PackageMakeInstall

- 1,510
- 4
- 22
- 39

- 51,413
- 19
- 159
- 217
-
3
-
-
Most instructions like this assume you have the "standard" compile/build packages, such as `make` and `gcc`, installed. Under Debian and Ubuntu these are drawn in by the build-essential meta package (`aptitude install build-essential`, see http://packages.debian.org/squeeze/build-essential). I believe the equivalent on RedHat (and so presumably CentOS too) is `yum groupinstall "Development Tools"`. You might separately need to add the `-devel` packages for less common libraries the software you are compiling may depend upon. – David Spillett Nov 14 '11 at 16:50
-
9
-
17While this is technically correct, for any sort of maintainability or repeatability, it is HIGHLY recommended to manage packages via RPM (or whatever your distro's packaging is) rather than manually building and installing from source on every machine where it's needed. A number of the answers below link to pre-built packages. – Jason Antman Aug 29 '12 at 19:35
-
5Trying to manage Node.JS and any of its ecosystem via RPM right now is an exercise in futility, and I say this as someone who briefly ran a yum repo containing Node and a number of module packages. – jgoldschrafe Oct 25 '12 at 11:24
-
There's nothing wrong with make install. As long as you're careful it's fine. Just remember to keep your installation directory so you can make uninstall if you want to upgrade later on. As jgoldschrafe said, you'll struggle to find a repo that keeps up to date releases and is 'safe'. Remember every time you add some weird foreign repo it could be filled with all kinds of nasties etc. – John Hunt Jan 03 '13 at 09:25
-
As of December 2012, nodejs-0.9.5 is in the Fedora Rawhide and Fedora 18 testing official repositories. You should be able to download the SRPM from them and `rpm --rebuild` it on centos or redhat with minimal effort. I hope it will make it to EPEL soon. – Jason Antman Jan 11 '13 at 18:34
-
This approach is pretty standard and the first one I thought to try (after yum). Alas, my python interpreter (2.4.3) insists that configure has syntax errors – Isaac Rabinovitch Feb 19 '13 at 05:01
-
5@IsaacRabinovitch They added a ternary `if`, which didn't come about until Python 2.5. Since CentOS follows the RHEL path of pegging the system Python to some custom-patched version of 2.4, my solution was to `yum install python26 python26-devel` and then execute `python26 configure` instead of `./configure`. Then, since the `Makefile` also executes Python scripts, I defined the `PYTHON` variable in there to be `python26` instead of `python`. Also, you're going to need `g++` on there, so if you haven't already, you should `yum install gcc-++`. – Hank Gay Mar 08 '13 at 16:13
-
My ancient-node was beyond any usefulness and I have work to do, so this seems the most 'manageable' solution available. To use this solution on CentOS 6.3, I also needed to install, via yum, ruby, ruby-devel, rubygems, and rpm-build. Thanks to this responder for making it possible to stay on CentOS. – JosephK Apr 23 '13 at 11:46
-
You *can* use yum to manage node, if you're on a recent 6.x release of CentOS and have the EPEL repo enabled. See my answer below. – geerlingguy Aug 08 '13 at 01:32
-
I'm on Centos 7 trying to install node 4.2.3 and the EPEL answer did not work for me. The nave.sh answer worked well. – jcollum Jan 09 '16 at 20:11
If you have CentOS 6.x, and have enabled the EPEL repository, you can use yum to install node/npm:
$ sudo yum install npm
After the installation is complete, check to make sure node is setup properly:
$ node -v
(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.

- 1,357
- 2
- 17
- 29
-
2This worked beautifully on my CentOS 6.4 system and gave me node and npm. I got node 0.10.13, just a little off the latest src tarball 0.10.15. It seems this need upvoting more to stand out as it trumps the 'install from source' option. – Neek Aug 07 '13 at 08:53
-
1Follow [this](http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x) to install EPEL repo. – Lee Chee Kiam Aug 15 '14 at 06:25
-
1to update enable epel repository run `yum install -y epel-release`, then you can install node and npm with yum. – svassr Dec 11 '15 at 15:00
-
I couldn't get the epel or epel-release to work with yum for v4.2.x. The nave.sh answer below worked beautifully. – jcollum Jan 09 '16 at 20:10
-
1Installing via yum gives me a very old version v0.10.42... How can I install Node via yum / rpm to get the latest version (currently 5.9.0)? – dokaspar Mar 18 '16 at 08:34
-
@dokaspar - I updated the answer with a link to the Nodesource yum repo installation instructions. That's my favorite way to install newer Node.js versions through yum. – geerlingguy Mar 20 '16 at 12:38
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.
$ wget https://raw.github.com/isaacs/nave/master/nave.sh
$ chmod +x nave.sh
$ ./nave.sh install 0.8.8
$ ./nave.sh use 0.8.8
$ node -v
v0.8.8
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"

- 379
- 3
- 4
-
1
-
-
FYI This seems to install it for this user only. If you want to install it for the entire system: ./nave.sh usemain
– awl Apr 23 '13 at 20:23 -
"nodejs becomes part of the standard repo" -- on CentOS 7 it's incredibly out of date. The version installed is v10.x (on the CentOS that our IT dept uses anyway). – jcollum Jan 09 '16 at 20:12
For CentOS
yum install gcc-c++ make git
cd /usr/local/src/
git clone git://github.com/joyent/node.git
cd node
./configure
make
make install

- 139
- 1
- 3
-
2You should be using a released version not the github version, unless you're planning on contributing to the node project. – B T Sep 27 '13 at 23:33
[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 :))
wget http://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm
yum localinstall --nogpgcheck nodejs-stable-release.noarch.rpm
yum install nodejs-compat-symlinks npm
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..

- 391
- 1
- 5
- 13
-
3
-
12
-
2
-
2@JohnHunt Installing from source means you can't cleanly uninstall any more. I've had this same problem with Ruby. Fortunately, I could just rollback the VM image... Installing from source means you need to have deep understanding of the package you're installing. Considering there are thousands of linux packages, this is not an option! – Christian Jan 24 '13 at 08:41
-
1"The link above"? Answers are sorted by vote, and Chris's is now below yours. – Isaac Rabinovitch Mar 09 '13 at 06:07
-
Thank you @IsaacRabinovitch for pointing it out.. as a matter of fact I'm pretty new here and I didn't realize that answers "move up" when upvoted :) – Luke Mar 26 '13 at 15:51
-
-
1If you are worried about installing software from source, then take a look at stow. http://www.gnu.org/software/stow/, which is conveniently available in default repositories on most distributions, including CentOS. It manages software installed from source using clever symlinking to approximate a package manager, allowing easy installs, upgrades, backups, and uninstalls. – Stephanie May 23 '13 at 23:25
-
1
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.

- 633
- 1
- 6
- 8
-
I would say the 0.6 version in your link is already quite obsolete. It seems there are really no good options for RHEL/CentOS right now, which is odd considering that [Red Hat itself offers node.js PaaS](https://openshift.redhat.com/community/get-started/node-js) – explunit Feb 16 '13 at 14:12
This worked for me on CentOS 5.7:
yum install openssl-devel
yum install python27
yum install gcc-c++
cd /usr/local/src
wget http://nodejs.org/dist/node-latest.tar.gz
tar zxvf node-latest.tar.gz
cd node-v[tab]
python2.7 configure
make PYTHON=python2.7
make install
-
3I have to use python 2.6 on my CentOS 5.10, as python 2.7 is not in repo. – ohho Feb 25 '14 at 04:03
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:
# get the latest stable binary
latest_node=$(curl http://nodejs.org/dist/latest/SHASUMS.txt | grep 'linux-x64.tar.gz' | awk '{ print $2 }')
wget -O ~/nodestable.tar.gz http://nodejs.org/dist/latest/$latest_node
cd /usr/local/
sudo tar xzvf ~/nodestable.tar.gz --strip=1
Or, if you want a specific version (e.g. to stay on the 0.8 series):
wget http://nodejs.org/dist/v0.8.22/node-v0.8.22-linux-x64.tar.gz
cd /usr/local/
sudo tar xzvf ~/node-v0.8.22-linux-x64.tar.gz --strip=1
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.
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
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.
The answers above are outdated
AS ROOT
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs
and you are done.
verify your install with
node -v

- 331
- 3
- 9
-
My version of curl doesn't seem to like the Signing Authority of the url's SSL certificate, and so the script fails silently. You can get past it using the curl -k option. – Spike Williams Jan 23 '15 at 19:14
-
Also, after you add -k to the curl command above, you also need to update reference to curl downloads from that domain in the "setup" script that gets downloaded. Then run that script manually using bash. – Spike Williams Jan 23 '15 at 19:22
No one mentioned nvm
to handle (multiple) safely and easily Node installations https://github.com/creationix/nvm? I find it so useful.
Even useful to build a Node release files tree and so custom rpm packages without scripting too much, latest-node
, wget
, ./configure
, make
, make install
blah blah.
nvm install 0.10.9
Will download binaries or compile source code according to the release.

- 457
- 1
- 6
- 12
Run as root on RHEL, CentOS or Fedora, for Node.js v4 LTS Argon:
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
Alternatively for Node.js v5:
curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
Alternatively for Node.js 0.10:
curl --silent --location https://rpm.nodesource.com/setup | bash -
Then install, as root:
yum -y install nodejs

- 151
- 1
- 3
-
The only answer that works for CentOS 7.2. And worked so quickly and perfectly.! – writeToBhuwan Oct 02 '16 at 20:30
-
recommendation: visit the NVM project on GitHub and get the definitive instructions from the README: https://github.com/creationix/nvm#installation – Kay V Jul 18 '18 at 04:23
I have some pretty straight-forward instructions, along with a .spec file here:
http://www.chrisabernethy.com/installing-node-js-on-centos-redhat/
You'll be compiling this from source, so you will need to ensure that you have all of the necessary packages for doing that on your system (gcc and friends). This set of instructions is for building an RPM, so if you are missing any required packages, rpmbuild will let you know which ones you need to install first.

- 39
- 1
-
1Welcome to Server Fault! Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – user9517 Nov 14 '11 at 16:20
-
Also, the link refers to /usr/src/redhat, which doesn't seem to exist in my CentOS 5 install (it's at /usr/local/src if I understand correctly) – Kato Nov 17 '11 at 20:11
-
2Recent changes would also require people to update their Python installation (or configure will not work on any CentOS server still using Python 2.4).. Consider freshening up the information and placing it here? – Tim Post Oct 03 '12 at 23:43
You'll also need npm
git clone https://github.com/isaacs/npm.git
cd npm
sudo make install

- 208
- 1
- 5
You can use nodebrew.
$ curl -L git.io/nodebrew | perl - setup
$ export PATH=$HOME/.nodebrew/current/bin:$PATH
$ source ~/.bashrc
$ nodebrew install-binary latest
$ nodebrew use latest
$ node -v

- 31
- 2
For Ubuntu, this worked for me for version 0.4.10
cd /usr/local/src/
sudo wget http://nodejs.org/dist/node-v0.4.10.tar.gz
sudo tar zxvf node-v0.4.10.tar.gz
cd node-v0.4.10/
sudo ./configure
sudo make
sudo make install

- 173
- 1
- 6
My answer for version 4+:
yum -y install wget
wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-x64.tar.gz
tar xzf node-v4.0.0-linux-x64.tar.gz -C /usr/local
rm -rf node-v4.0.0-linux-x64.tar.gz
mv /usr/local/node-v4.0.0-linux-x64 /usr/local/node
ln -s /usr/local/node/bin/node /usr/bin/node
ln -s /usr/local/node/bin/npm /usr/bin/npm
Check in the folder https://nodejs.org/dist/latest/ to find the download link for the latest version.

- 123
- 1
- 6
-
This saved me on CentOS server running Plesk - building the latest version (5) from source fails since gcc is so out of date. I'd update gcc but usually updating anything manually via yum turns Plesk into a screaming child. – twistedpixel Nov 19 '15 at 18:41
-
is there a tar for 4.x stable? The answer will be better if it survives a few version changes. – jcollum Jan 09 '16 at 01:34
-
I edited my answer to include a link to the latest distribution folder where you can find the distro-specific install. – Evan Siroky Jan 09 '16 at 16:16
here is my Dockerfile which installed node v0.10.36 in centOS 7
FROM centos:7
RUN yum -y update
RUN yum -y install vi, vim, unzip, tar
RUN yum -y install wget, curl, git
RUN yum -y install epel-release
RUN yum -y install npm

- 121
- 2
Below code worked pretty well on CentOS 6
wget http://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm
yum localinstall --nogpgcheck nodejs-stable-release.noarch.rpm
yum install nodejs-compat-symlinks npm
It does not work anymore, http://nodejs.tchol.org is not online anymore.

- 1,770
- 5
- 19
- 29

- 27
- 1
I went thru the task of doing this installation myself on RHEL 5.8 not too long ago. Unfortunately, with nodejs.tchol.org going offline, the only option is to build it from source.
However, the build process got quite a bit complicated as the build script involves python code that doesn't work with the default version of Python on RHEL. After a lot of trial and error (and a lot of googling), I found this blog post which basically describes a step to step on the following tasks required.
a. Install Python 2.6 b. Setup that version of python as an alternate version, then setting it as default c. configure and install node.js d. Switching Python back to the default 2.4 version.
The key is that you should switch back to Python 2.4 afterwards; otherwise, simple things like yum will fail.
http://www.robeesworld.com/blog/31/installing_node_js_0_8_under_centos_5_8

- 126
- 2
After installing using the top-rated answer, i was unable to install any global modules (-g) without Sudo permissions. NPM update showed errors. Below method worked perfect for me, there is no need for SU or SUDO permissions.
I installed Node.js and NPM using the below method taken from (https://gist.github.com/isaacs/579814) but modified two lines of commands as per the advise from a comment posted by deesejohn in that page.
cd
sudo yum install gcc-c++
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=$HOME/local
make install
curl -L https://www.npmjs.org/install.sh | sh
Check installed version using node -v
and npm -v

- 111
- 3