Skip to content

How to Install NVM on CentOS Stream 9 & RHEL 9

Steps
5
Covers
CentOS, Node.js, NVM
On this page 5 steps

Node Version Manager (NVM) is a popular utility that enables you to manage multiple versions of Node.js on your system. It allows you to switch between different Node.js versions easily, making it a valuable tool for developers working on different projects with varying requirements. In this article, we will guide you through the process of installing NVM on CentOS Stream 9 and RHEL 9.

Prerequisites

Before we begin, ensure that you have the following:

  • A system running CentOS Stream 9 or RHEL 9
  • A user account with shell access

Step 1 of 5Update Your System

First, it’s a good idea to update your system to ensure you have the latest packages and security updates. Run the following command:

sudo dnf update -y 

Step 2 of 5Install Build Tools

To compile and install Node.js versions, you will need some build tools. Run the following command to install them:

sudo dnf groupinstall "Development Tools" -y 

Step 3 of 5Install NVM

Now, we will install NVM by using the official install script from the NVM GitHub repository. Run the following command to download and execute the script:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash 

Note: The version number (v0.39.3) may change, so be sure to check the NVM repository (https://github.com/nvm-sh/nvm) for the latest release.

Once the script finishes execution, it will install NVM and add the necessary lines to your shell’s configuration file (such as .bashrc, .zshrc, or .bash_profile).

To apply the changes, you need to restart your shell or run the following command:

source ~/.bashrc 

To verify that NVM is installed correctly, run:

nvm --version 

If you see the version number displayed, NVM is successfully installed.

Step 4 of 5Install Node.js

With NVM installed, you can now install different versions of Node.js. To install the latest LTS (Long Term Support) version, run:

nvm install --lts 

To install a specific version, use the following command:

nvm install 18.16.0  

Replace “18.16.0” with the desired version number.

Step 5 of 5Switch Between Node.js Versions

NVM allows you to switch between installed Node.js versions easily. To switch to a specific version, use the following command:

nvm use 18.16.0  

Replace “18.16.0” with the version number you want to switch to.

To view a list of all installed Node.js versions, run:

nvm ls 

To set the default Node.js version that will be used every time you open a new terminal, run:

nvm alias default 18.16.0  

Replace “18.16.0” with the desired version number.

Conclusion

You have now successfully installed NVM on your CentOS Stream 9 or RHEL 9 system and learned how to manage multiple Node.js versions. With NVM, you can easily switch between different Node.js versions to work on projects with varying requirements.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top