The Node Version Management also known as the NVM is used to manage the different versions of Node.js on a single computer. Using the NVM, different versions of Node.js can be installed and uninstalled on the computer and it can also be used to switch between different versions of Node.js.
The package of the NVM can be installed on different Linux distributions including Debian and Ubuntu. This post demonstrates the installation method of the NVM on Debian with its basic usage following the outline:
- What is the Method to Install NVM on Debian Linux
- What is the Basic Usage of NVM Package on Debian Linux
- Examples
- How to Uninstall the NVM on Debian
Start the post with the installation method of NVM on Debian.
What is the Method to Install NVM on Debian Linux?
To install the NVM on Debian, simply download the installation script of NVM. Then run the downloaded script to install the NVM on Debian.
NVM installation has been explained with the complete step-by-step guide.
Step 1: Update the Package List
The first and advised step is to update the package list of Debian with the following command:
$ sudo apt update
Step 2: Install the Dependencies
The next step is to install the dependencies including the wget and curl command utilities on Debian 12 by running the command:
$ sudo apt install build-essential libssl-dev wget curl -y
Step 3: Download the NVM Installation Script
Now download the NVM bash script from the official website of GitHub. If the package is supposed to download with the curl command, then use the command:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
The same installation script can be downloaded by using the wget command. For this, execute the next-mentioned command:
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Step 4: Source NVM
To apply the changes permanently, run the following command:
$ source ~/.bashrc
Step 5: Verify the Installation of NVM
Display the installed version of the NVM to verify its installation with the command:
$ nvm --version
The output is validating the successful installation of the NVM on Debian.
What is the Basic Usage of NVM Package on Debian Linux?
The NVM is used to manage different versions of Node.js on Debian 12. The usage of the NVM has been explained in the next examples.
Example 1: List the Available Versions
To list down all the available versions of Node.js that can be installed on Debian using the NVM, run the command:
$ nvm ls-remote
All the versions have been listed down, select one and follow the next example.
Example 2: Install the Node.js on Debian
Now from the available versions, select the version, for instance, install the 12.20.7 version with the command:
$ nvm install 12.17.0
Example 3: Install the Latest Version (Stable)
To install the latest version of the Node.js on Debian, execute the command:
$ nvm install --lts
Example 4: Install the Latest Version (Unstable)
To install the latest and newest version of the Nodejs that is unstable, run the command:
$ nvm install node
Example 5: List Installed Versions of Node.js
To list down all the installed versions of the Nodejs on Debian, execute the command:
$ nvm ls
Example 6: Set the Default Version
To set the specific version of the Nodejjs on Debian 12 using the nvm, execute the command:
$ nvm alias default 20
Example 7: Switch the Version
To switch to the other installed version of Nodejs, use the command:
$ nvm use 12.17
Example 8: Find the Current Version of Nodejs
Run the command, to find the current version of the Nodejs running on Debian:
$ nvm run default --version
Example 9: Execute the Nodejs Script
To execute the node.js script with the particular installed version of Nodejs, run the command:
$ nvm exec 14.18.0 backoffice.js
Example 10: Switch to the system-installed NodeJS
Run the next mentioned command for switching to the system-installed Nodejs:
$ nvm use system
Example 11: Deactivate the Nodejs
To deactivate the Nodejs instead of uninstalling it, run the command:
$ nvm deactivate
Example 12: Uninstall the NVM
To uninstall the nodejs on Debian, specify the version and execute the below-mentioned command:
$ nvm uninstall 20
Example 13: Explore the NVM
To explore more options of the NVM on Debian, open its help menu with the command:
$ nvm --help
How to Uninstall the NVM on Debian?
To uninstall the NVM, simply remove its downloaded script:
$ sudo rm -rf ~/.nvm
Confirm the uninstallation by displaying the version details of the NVM:
$ nvm --version
This is all about the installation and usage of the NVM on Debian.
Conclusion
To install the NVM on Debian 12, download the installation script of NVM from GitHub using the wget or curl command utility, then run the downloaded script to complete the installation.
NVM is used to manage different versions of Nodejs on Debian. This blog demonstrated the installation with the basic usage of the NVM to manage Nodejs.