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

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

yum install -y gityum install -y makecurl -L --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 or 8.16.0
  • Any major version of Node.js, e.g. 13, 14 or 15. In this case, the latest version of the major version will be installed.

Let’s explain the magic:

  • yum install -y git to install git command line on the machine. The -y option tells yum to answer yes to the questions being asked during installation.
  • Similarly, yum install -y make is to install make.
  • curl -L --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 allows n-install to be executable.
  • yes y | ./n-install execute n-install and say yes 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!

Software developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store