DEV Community

DoctorIT
DoctorIT

Posted on

10

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!!!

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay