Install specific version of Node.js using NVM on CentOS 8

During development, we may need to use different versions of Node.js on the same machine. This is where the Node Version Manager (NVM) comes in handy. NVM is a tool for managing multiple Node.js versions, which allows you to install and switch between different Node.js versions on the same machine. In this article, I will show you how to install a specific version of Node.js on CentOS 8 using NVM.

## Install NVM

First, we need to install NVM on our system. We can do this by running the following command:

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

This command will download the NVM installation script from GitHub and run it. Please note that you may need to modify the version number in the above command according to the latest version of NVM.

## Update shell configuration

After installing NVM, we need to close and reopen our terminal, or run the following command to update our shell configuration:

source ~/.bashrc

## Install a specific version of Node.js

We can then install a specific version of Node.js with the following command:

nvm install 20.3.1

In this example, we installed version 20.3.1 of Node.js. You can modify the version number in the above command according to your needs.

## Switch Node.js version

After installing Node.js, we can use the following command to switch to the version of Node.js we just installed:

nvm use 20.3.1

## verify installation

Finally, we can verify that Node.js has been successfully installed with the following command:

node -v

If Node.js has been successfully installed, the above command will output the version number of Node.js we installed.

## in conclusion

That's all for installing a specific version of Node.js on CentOS 8 using NVM. By using NVM, we can easily manage multiple Node.js versions on the same machine, which is very useful for development and testing. Hope this article helps you!

Guess you like

Origin blog.csdn.net/juedaifenghua2/article/details/131448534