NVM is a version manager for Node.js used to install and manage multiple Node.js versions in Linux. It is a command-line utility and provides several options for the easy installation of Node.js. It allows you to download and install any version of Node locally with a simple command.
In this guide, we will walk you through the installation of NVM on Debian 11.
How to Install NVM on Debian 11
Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:
$ sudo apt update $ sudo apt upgrade -y $ sudo apt install build-essential curl gnupg2 -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
[ads1]
Next, reload the .bashrc file to apply the changes.
$ source ~/.bashrc
[box type=”note” align=”” class=”” width=””]Alternatively, simply log out and log in again. [/box]
Now, verify the NVM version using the following command:
$ nvm --version
You should see the following output:
0.38.0
Install Node.js with NVM
To install the latest version of Node.js, run the following command:
$ nvm install node
You should see the following output:
Downloading and installing node v16.9.0... Downloading https://nodejs.org/dist/v16.9.0/node-v16.9.0-linux-x64.tar.xz... ######################################################################################################################################## 100.0% Computing checksum with sha256sum Checksums matched! Now using node v16.9.0 (npm v7.21.1) Creating default alias: default -> node (-> v16.9.0)
To verify the installed version of Node.js, run the following command:
$ node --version
You should see the following output:
v16.9.0
If you want to install the latest stable version of Node.js run the following command:
$ nvm install node --lts
You should see the following output:
[ads1]
v16.9.0 is already installed. Now using node v16.9.0 (npm v7.21.1)
To install the specific Node.js version (12.17.0), run the following command:
$ nvm install 12.17.0
You should see the following output:
Downloading and installing node v12.17.0... Downloading https://nodejs.org/dist/v12.17.0/node-v12.17.0-linux-x64.tar.xz... ######################################################################################################################################## 100.0% Computing checksum with sha256sum Checksums matched! Now using node v12.17.0 (npm v6.14.4)
Now, verify the current Node.js version using the following command:
$ node --version
You should see the following outpu
v12.17.0
Use NVM to Manage Node.js Versions
To list all installed Node.js versions in your system, run the following command:
$ nvm ls
You should see the following output:
-> v12.17.0 v16.9.0 default -> node (-> v16.9.0) iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v16.9.0) (default) stable -> 16.9 (-> v16.9.0) (default) lts/* -> lts/fermium (-> N/A) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.24.1 (-> N/A) lts/erbium -> v12.22.6 (-> N/A) lts/fermium -> v14.17.6 (-> N/A)
You can find the all available Node.js versions using the following command:
$ nvm ls-remote
To set your default Node.js version to 12.17.0, run the following command:
$ nvm use 12.17.0
You should see the following output:
Now using node v12.17.0 (npm v6.14.4)
To find the default version for the current user, run the following command:
$ nvm run default --version
You should see the following output:
Running node v16.9.0 (npm v7.21.1) v16.9.0
You can also run a Node application with a specific Node.js version using the following command:
$ nvm run v12.17.0 app.js
To remove a specific Node.js version from your system, run the following command:
$ nvm uninstall v12.17.0
[ads1]
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.