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.

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 package manager:

dnf module -y install nodejs:<stream>

where 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 can be:

  • Any Node.js version, e.g. or
  • Any major version of Node.js, e.g. , or . In this case, the latest version of the major version will be installed.

Let’s explain the magic:

  • to install command line on the machine. The option tells to answer to the questions being asked during installation.
  • Similarly, is to install .
  • is download n, a Node.js version manager. The option tells curl to accept URL redirect. option allows the result to be saved into a file.
  • allows to be executable.
  • execute and say to question asked during the installation process.
  • With installed on the machine, will install any version of Node.js.

Have fun with Node.js!

Software developer