How to install specific version of Node.js on RedHat-based Linux
Solutions to install any versions of Node.js on a RedHat-based Linux, including RedHat, Fedora, Oracle Linux and Centos.
2 min readJan 11, 2021
Installing latest version of a specific Node.js stream
The latest Long-Term-Support (LTS) version of Node.js can be installed to RedHat-based Linux using the dnf
package manager:
dnf module -y install nodejs:<stream>
where <stream>
corresponds a major LTS version of Node.js, e.g. 10, 12 or 14. You can list the available streams using:
dnf module list nodejs
This method will only allow you to install the latest LTS versions, e.g. at the time of writing
- v8.17.0 for Node.js 8
- v10.23.1 for Node.js 10
- v12.20.1 for Node.js 12
- v14.15.4 for Node.js 14
If you want to install a specific version of Node.js, you need to be more involved.
Installing any Node.js version
This is the magic script that will install any Node.js version you like into your Linux machine:
yum install -y gityum install -y makecurl -L https://git.io/n-install --output n-installchmod +x n-installyes y | ./n-install$HOME/n/bin/n <version> yum clean all
where <version>
can be:
- Any Node.js version, e.g.
15.5.1
or8.16.0
- Any major version of Node.js, e.g.
13
,14
or15
. In this case, the latest version of the major version will be installed.
Let’s explain the magic:
yum install -y git
to installgit
command line on the machine. The-y
option tellsyum
to answeryes
to the questions being asked during installation.- Similarly,
yum install -y make
is to installmake
. curl -L https://git.io/n-install --output n-install
is download n, a Node.js version manager. The-L
option tells curl to accept URL redirect.--output
option allows the result to be saved into a file.chmod +x n-install
allowsn-install
to be executable.yes y | ./n-install
executen-install
and sayyes
to question asked during the installation process.- With
n
installed on the machine,$HOME/n/bin/n <version>
will install any version of Node.js.
Have fun with Node.js!