NVM stands for Node Version Manager, which is a command-line utility for installing Node.js. It allows the programmers for installing Node.js in their account only. This means the installation is done user-specific. All the users in a single system have their own installation of Node.js.
Using the nvm utility, we can install the multiple node.js versions in a single account and manage them easily. The application can have use .nvmrc
at root folder to autoselect the Node.js version.
This tutorial will help you to install nvm on Debian 11 “bullseye” Linux system.
Prerequisites
- Assuming that you have a running Debian 11 Bullseye Linux system with shell access. No need to have sudo access.
- Login to the system and open a shell in your account
- The newly installed system are requested to complete initial server setup on Debian 11.
How to Install NVM on Debian 11
A shell script is available for the NVM installation on any Linux system. First of all, check if your system has installed the curl command-line utility. If not, use the following command to install curl.
sudo apt install curl -y
Then execute the NVM installation bash script as your user. No need to use sudo with the installation script.
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
The above script makes all the required environment settings to the login script of the currently logged-in user. To apply the settings log out and log in again to your account or just execute the below command to do the same.
source ~/.bashrc
How to Install Node.js on Debian 11
The nvm allows you to install multiple Node.js versions for a single user account. Use the following commands to install the required node.js version on your Debian 11 system.
- Install Latest Node Version – This is the most recent version released for the installation by Node.js team. You can use “node” as alias for the latest version.
nvm install node
- Installing Latest Stable Node Version – Use the
--lts
option with command line to install latest LTS (Long Term Release) version.nvm install node --lts
- To install a specific version of node:
nvm install 12.20.1
Change
12.20.1
with your required Node.js version to install on Debian 11 system.
The very first version installed becomes the default. New shells will start with the default version of node (e.g., nvm alias default).
How to Use NVM?
Here are some useful options to use with the nvm command-line utility.
You can use the following command to list installed versions of Node for the current user.
nvm ls
With this command, you can find the available Node.js version for the installation.
nvm ls-remote
You can also select a different version for the current session. This will be a current active version for the current shell only.
nvm use 12.20.1
To find the default Node version set for the current user, type:
nvm run default --version
You can run a Node script with the desired version of node.js using belwo command:
nvm exec 12.20.1 server.js
Conclusion
This tutorial helped you to install nvm on Debian 11 Bullseye Linux system. Additionally provided you the basic instructions to use the NVM utility.