Surya.dev
Published on

Nodejs Multiple Version with NVM

Authors

In this blog we will learn to use NVM (Node Version Manager). NVM is used to manage and switch between different versions of Node.js on our computer. NVM allows us to install, uninstall, and change the current version of Node.js as needed. Here are some of the main benefits of NVM.

  • Managing Node.js Versions which means we can install several versions of Node.js on a personal computer at the same time. This is useful when we work on projects that require different versions of Node.js.
  • Switching Between Node.js Versions With NVM, we can easily switch between different Node.js versions without having to reinstall or delete existing versions. we can select the appropriate Node.js version for a particular project with the nvm use command.

To install NVM, you can go to the check detail official github nvm. On this blog I use remote ssh-ubuntu.

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

after that, we can check whether nvm was successfully installed with the following command nvm -v

terminal
nvm -v
Image nvm output

List of available Node.js versions

To see a list of all available Node.js versions that we can install with nvm, run the following command:

terminal
nvm ls remote

Install the desired version

To install a specific version of Node.js, such as version 16, use the following command:

terminal
nvm install 16.17

Replace "16.17" with the version we want. After running this command, nvm will download and install the version of Node.js we specified.

Overriding the active Node.js version:

To change the active Node.js version using nvm (Node Version Manager), we can use the following command:

terminal
nvm use <node_js_version>

Replace node_js_version with the version of Node.js you want to use. For example, if we want to switch to the Node.js 16 version that you installed previously, you can run the following command:

terminal
nvm use 16

This will set the active Node.js version to the version we specified, and we can check whether the version has changed by running the node -v command to check the currently active version.