In this guide, you will learn:
- How to Install NVM on Debian 12
- How to Use NVM on Debian 12
- How to Remove NVM from Debian 12
The NVM officials have provided a bash script that makes the NVM installation quite simple on Linux systems without installing any additional dependencies. You must download the script from the official website and run it on your terminal using the following command to successfully install NVM on Debian 12.
After the execution of the above command, close your terminal and open it again so that the changes will be applied. You can also run the provided echo command to avoid restarting the terminal.
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Once the changes are made, check the NVM version on Debian 12 using the following command to ensure it is successfully installed on the system:
You can use NVM on Debian 12 to:
- Install Multiple Versions of Node.js
- Switch to Any Node.js Version
- Uninstall a Specific Node.js Version
- Run JS File
You can use NVM on your Debian system to install multiple Node.js versions on the system that could be the latest one, stable one or the older one depending on the version you want to install.
If you want to install the Node.js latest stable version on Debian 12 using NVM, you can run the nvm install command with the node keyword:
If you want to install a specific Node.js version on Debian, you can use the nvm install command and the version number you want to install:
Here, I am installing Node.js version 9.0 using NVM on Debian 12 through the following command:
If you want to install a stable version of Node.js on Debian 12 through NVM, you can use the nvm install command followed by the stable keyword:
Note: You can find the list of Node.js versions from NVM on Debian using the following command:
Switching to a different Node.js version is crucial, since there are some applications that only operate on a specific Node.js version. Thus, besides removing the previous version and installing another version, it is better to use NVM to install multiple Node.js versions and switch to them with ease.
To use a specific Node.js version on Debian, you can run the nvm use command followed by the node version. Here, I am using the Node.js latest stable version on Debian, which is installed through node keyword:
Note: Replace node with the Node.js version you want to use on the Debian system. It is also necessary that the switching process will only work if a specific Node.js version is installed on the system through NVM.
To check your system uses the current Node.js version, use the below-given command:
You can also use NVM to uninstall any Node.js version installed on the system through it. It can be done by running the nvm uninstall command, followed by the version you want to remove from the system:
Note: You must switch to any other Node.js version if you are going to remove a version that the system is currently using.
You can also use NVM to run your JS file on Debian, this can be done by using nvm run command followed by the Node.js version number and JS file name you want to run.
If you don’t like using NVM on Debian 12, you can remove it any time by removing the NVM source file from the system using the following command:
NVM is an effective command-line utility for allowing installation of multiple Node.js versions on Linux systems including Debian. You can install NVM on Debian 12 by downloading and running the official bash script file. Then, close and reopen the terminal to ensure NVM is successfully installed on the system. Once you complete the NVM installation, you can install any Node.js version on Debian 12 by using the nvm install command with the version number of your choice. This article has provided a detailed guide for installing and using multiple Node.js versions on Debian, helping you to switch to any Node.js version and seamlessly run applications.