CentOS, Red Hat, and Fedora do not offer the latest version of Node.js in their default repositories. The version available in the epel repository is often outdated. To install the most recent version, you need to use the NodeSource repository.
The NodeSource repository is a reliable source for the latest Node.js versions. It ensures that your system is equipped with the most up-to-date features and security updates. This method is the recommended approach for installing and maintaining Node.js on these distributions.
Using NodeSource simplifies the process of keeping Node.js current on your system. By adding this repository, you can easily install and update Node.js to the latest version available. This ensures your system remains efficient and secure.
You can install a more stable and tested version of Node.js by installing the one provided in the epel repository.
Related: How to install Node.js on CentOS / Red Hat / Fedora
Steps to install latest version of Node.js for CentOS, Red Hat or Fedora:
- Install curl on your system if it is not already available.
$ sudo yum install --assumeyes curl
- Add the NodeSource repository to your system.
$ curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
Replace 10.x with 12.x, 11.x or 9.x depending on your requirement
- Install the latest version of Node.js from the NodeSource repository.
$ sudo yum install --assumeyes nodejs ########################## ============================================================================================== Package Arch Version Repository Size ============================================================================================== Installing: nodejs x86_64 2:10.9.0-1nodesource nodesource 18 M Transaction Summary ============================================================================================== Install 1 Package ##########################
npm is automatically installed in nodejs package and does not require separate installation.
- Verify the installation by checking the version of Node.js.
$ node -v v10.9.0
- Verify the installation of npm, which is included with Node.js.
$ npm -v 6.2.0

Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.