DEV Community 👩‍💻👨‍💻

Aeedy Adithep
Aeedy Adithep

Posted on

How to upgrade Node.js on Centos

This blog I want upgrade Node.js to current statble version on Centos. Here is step by step.
Check existing node.js version on machine

Image description

Following step with command line
clear cache

sudo rm -rf /var/cache/yum
sudo yum remove -y nodejs
Enter fullscreen mode Exit fullscreen mode

and also remove node.js directory

sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/include/node*
sudo rm -rf /usr/local/bin/node*
Enter fullscreen mode Exit fullscreen mode

Install latest version
I need install stable of Node 16.x LTS.
Add NodeSource yum repository

curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
Enter fullscreen mode Exit fullscreen mode

and the output like here

## Run `sudo yum install -y nodejs` to install Node.js 16.x and npm.
## You may run dnf if yum is not available:
     sudo dnf install -y nodejs
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn
Enter fullscreen mode Exit fullscreen mode

Install package

sudo yum install -y nodejs
Enter fullscreen mode Exit fullscreen mode

Check node.js and npm version

Image description

Cheer!!!

Top comments (0)

Create an Account!

👀 Just want to lurk?

That's fine, you can still create an account and turn on features like 🌚 dark mode.