If you are looking to easily install Node.js on your CentOS, CloudLinux, or Red Hat Enterprize Linux, this tutorial will quickly show you how to, along with supplying the commands needed. This method will also grant you an RPM GPG key, along with assigning the repository for future updates through YUM or DNF.
This will install the latest Node.js version 14.x.xx for server-wide use. This will also install Node.js v14 on any CentOS, CloudLinux, or RHEL server with a hosting control panel including cPanel, DirectAdmin, Cloudmin, and any others.
First, make sure Curl is installed to execute the installation of Node.js
sudo yum -y install curl
sudo DNF -y install curl
Then install the Node Source RPM using Curl:
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
Then run the following command to install Node.js. The latest version of Node.js 4 will be installed.
sudo yum install -y nodejs
sudo dnf install -y nodejs
After, the following command can be run to verify Node.js is installed and which version of 14 is installed.
The following Node.js development tools may be of interest to install.
sudo yum install gcc-c++ make
The Node.js package manager NPM installs by default with the above command. If the Node.js package manager Yarn is desired, the following commands will install is and set up the RPM and future updates.
Install the Repostiroty Package Manager from Yarn:
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
Install Yarn Node.js Package Manager with the following command. This will install the latest version of Yarn.
sudo yum install yarn
sudo dnf install yarn
That's is it. Your server now has the latest version of Node.js installed and ready to use, along with Yarn, GCC-C++, and Make. Have fun developing in the world of Node.js