Steps to install Node.js on CentOS
Removing old nodejs versions.
yum remove nodejs
Step 1 - Add the Node.js Yum Repository
First, you need to enable the node.js yum repository on the system provided on the official Node.js website. You will also need to develop tools to build the native add-ons to be installed on the system.
yum clean all && yum makecache fast yum install -y gcc-c++ make curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -
yum clean all && yum makecache fast yum install -y gcc-c++ make curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash -
Step 2 - Install Node.js on CentOS.
After adding the yum repository to your system, let's install the Node.js package. npm will also be installed along with node.js. This command will also install many other dependency packages on your system.
sudo yum install nodejs
Step 3 - Check Node.js and NPM versions
Verify and check the installed version after installing node.js. You can find more details about the current version on the official node.js website.
node -v // v12.3.1
Also, check the version of npm
npm -v // 6.9.0
At this point, Node.js has been installed.