How to Install NVM on Debian 12- Installing Multiple Node.js Versions

Node Version Manager or NVM is a command line tool for Linux systems including Debian 12 used for installing and managing multiple Node.js versions. It is a useful tool for users who want to work on a project that requires specific Node.js versions on the system. Without using the lengthy and complex installation process, you can quickly install and switch to any Node.js version with ease. NVM installs each Node.js in a separate directory to avoid conflicts between the versions, allowing switching within no time.

In this guide, you will learn:

How to Install NVM on 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.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

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.

export NVM_DIR=$HOME/.nvm”

[ -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:

How to Use NVM on Debian 12

You can use NVM on Debian 12 to:

How to Install Multiple Versions of Node.js on Debian 12

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:

How to Switch to Any Node.js Version Using NVM on Debian 12

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:

How to Uninstall a Specific Node.js Version Through NVM on Debian 12

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:

node uninstall version_no

Note: You must switch to any other Node.js version if you are going to remove a version that the system is currently using.

How to Run JS File on Debian 12 Through NVM

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.

nvm run version_no filename.js

How to Remove NVM from Debian 12

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:

Conclusion

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.

source

Leave a Comment