How to Install and Use NVM (Node Version Manager) – Linode

The Node Version Manager (

NVM) is an open source version manager for Node.js (Node). NVM is easy to understand and works in any POSIX-compliant shell (e.g. sh or bash). NVM allows you to easily install and manage different versions of Node and switch between them by shell. This guide describes how to install NVM and how to use it to install and run different versions of Node.

The advantages of NVM

Node change quickly and testing applications with different versions is often difficult. Since NVM allows for quick and effortless switching between Node versions, it’s much easier to test version compatibility and updates with multiple libraries. NVM stores Node versions and associated modules within your user directory, so you don’t need to use sudo. NVM also simplifies the installation and build process because Node versions no longer have to be obtained directly from the distribution channel.

An overview of the NVM installation and configuration process

A complete NVM installation consists of the following high-level steps. Each step is described below.

NVM Installation and Configuration Using NVM to install the

  1. node
  2. Using NVM to

  3. run nodes
  4. Creating NVM

  5. aliases
  6. Install


These instructions show how to install NVM and are generally valid for most Linux distributions, although some of the .bashrc directives may vary slightly in different shells. You can install and use NVM regardless of whether you have already installed Node. NVM alters path variables to select different versions of Node, so it works with pre-existing installations.

Install NVM using curl or wget. To install NVM using curl, run the following command:curl -o- | bash

  1. To install NVM using wget, run the following command:wget

    -qO- | bash

  2. Source the new instructions that NVM added to .bashrc during the installation process. You can exit and re-enter the shell console, or manually the source of the .bashrc file. This file is almost always located at the root of your home directory.

    source ~/.bashrc

    As an alternative method, you can run the new statements in the same console to apply them immediately

    . export NVM_DIR=”$HOME/.nvm” [ -s “$NVM_DIR/” ] && \. “$NVM_DIR/” # This loads nvm [ -s “$NVM_DIR/bash_completion” ] && \. “$NVM_DIR/bash_completion” # This loads

  3. nvm bash_completion

  4. Confirm that you have successfully installed

    NVM. -v nvm command

    If the installation was successful, NVM returns nvm. If you see the message nvm: Command not found, confirm that the original installation completed successfully and repeat step #2 in this section to obtain the .bashrc file.


  5. You can confirm the version of NVM

  6. that is running with the following command:

    nvm –

version Use NVM to install the


The NVM install command downloads, compiles, and installs the specified version of Node. You can install as many versions of Node as you want.

To install the

  1. latest version of Node, run the following:nvm install node

    After a successful installation, NVM displays information about the installation.

    Now using node v15.5.1 (npm v7.3.0) Default alias creation: default node -> (-> v15.5.1)

  2. To install a specific version of Node, specify the major or minor version number. You can preview a list of all available Node versions with the ls-remote command.

    nvm ls-remote

    NVM displays a long list of versions available in the following format:

    v5.12.0 v6.0.0

  3. Install any additional version of Node you want to use. You can specify a major or minor version of Node to install. When you install a new version of Node, NVM immediately starts using it and designates it as the current version.

    nvm install 13.10.1 # Specific minor version nvm install 14 # Specify only the major


List of node

versions with NVM Review all installed versions of Node with the ls

  1. command. nvm ls NVM returns a list

    of all Node versions

    and aliases, along with an arrow indicating the current version. Here is an example output:

    v13.10.1 v14.15.4

-> default v15.5.1 -node > (-> v15.5.1) iojs -> N/A (default) node -> stable (-> v15.5.1) (default) stable -> 15.5 (-> v15.5.1) (default)

The use command of NVM

To select a different version of Node, use the nvm use command. Specify the Node version number (major or minor version) or an alias as a node.

nvm use node


nvm use 14

NVM confirms that you are now using the new version.

Now using node v14.15.4

you can also confirm the current version of Node with nvm current.

Current NVM returns

the current version number again

. NVM v14.15.4:

Change node


To switch to a different version of Node and immediately open a Node console, use nvm run. The run command is very similar to using nvm in all other respects.

nvm run node

NVM confirms that you are now running the selected version of Node and returns a Node indicator.

Running node v15.5.1 (npm v7.3.0) Welcome to node .js v15.5.1. Type “.help” for more information. >Creating NVM


You may want to refer to a version of Node with a different or easier to remember name. NVM already provides some pre-made defaults, such as default and node, which refers to the latest version. But you can use the alias command to change the value of an existing alias or create a new alias.

  1. Use the nvm alias command to change the default version of the node. Follow the alias keyword with the default alias and the new version of Node to reference.

    nvm alias default 14

    NVM confirms the new value for

    the alias. default -> 14 (-> v14.15.4)

  2. Use the nvm alias command to create a new alias. The following example sets a new servicing alias to Node version 13.10.1.


  3. alias maintenance 13.10.1 NVM confirms the new alias. maintenance -> 13.10.1 (-> v13.10.1)

  4. You can display all new and old aliases with the nvm ls command. nvm ls

Use NVM to install the latest version of LTS

node .js

Any version .js node can be in one of the following three release phases: “Current”, “Active Long-Term Support (LTS)” and “Maintenance”. The LTS release version of Node.js includes new features, bug fixes, and updates that have been approved to be part of the release lineup. This section shows you how to install the latest LTS version of Node.js using NVM.

Use the following command to install the latest LTS version

of Node.js on your system

:nvm install -lts

You should see the following output:Installing the

latest LTS version. Downloading and installing node v16.15.1… Downloading…#### Now using node v16.15.1 (npm v8.11.0)

Once the installation is complete, NVM automatically switches to the latest LTS version of Node.js which you just installed.

To install a specific LTS version line

(a version other than the latest version), use the -lts argument together with the name of the version line that you want to install. nvm install -lts


The example command installs the LTS line “argon” from Node.js. See the Node.js Releases page for LTS version names.

To switch to the latest LTS version of Node.js

which is already installed on your system

, use the following command:nvm use -lts Now using node v16.15.1 (npm v8.11.0)To switch to a specific LTS version of Node.js, use the following command:nvm use lts/argon

The example command changes to the LTS line “argon” of Node.js.

Now using node v4.9.1 (npm v2.15.11)


NVM capabilities

Although NVM is very easy to use, it also provides some advanced capabilities. See the NVM GitHub page for a complete list of all advanced topics.

  1. NVM allows you to migrate packages from an earlier version of Node. The nvm install command can be used with the optional -reinstall-packages-from= flag to install a new version of Node with packages from a previous version. The following command installs the latest version of Node, but also reinstalls the packages from the default version of Node and links them.

    nvm install node -reinstall-packages-from=default

  2. NVM allows you to define custom colors to display the various versions and aliases of Node. These colors are defined on the NVM GitHub page. Use the nvm set-colors <color-key> command. If you add the -no-colors flag to a command, the information is displayed in black and white.

    nvm set-colors rgBcm

  3. You can also specify a default node version number within the .nvmrc file. This file can be located in the root directory or any parent directory. The version indicated in .nvmrc is used if no version is specified on the command line.

Using NVM to uninstall Node NVM allows you to uninstall versions of Node

that are no longer needed

. Run the nvm uninstall command with the version of Node you want to remove.

  1. You cannot delete a version that you are currently using, so you must first switch to a different version.

    nvm uninstall 13.10.1

    NVM confirms that the Node version has been removed.

    Uninstall node v13.10.1

NVM uninstall steps

If you no longer want to use NVM, you can uninstall it with the unload command.

  1. Disable NVM with the nvm deact command. This deletes any path variables.

    nvm disable

  2. Uninstall NVM.


  3. nvm

  4. Clean up your .bashrc file by deleting the following lines:

    export NVM_DIR=

“$HOME/.nvm” [ -s “$NVM_DIR/” ] && \. “$NVM_DIR/” # This loads nvm [ -s “$NVM_DIR/bash_completion” ] && \. “$NVM_DIR/bash_completion” # This loads nvm



You may want to refer to the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot guarantee the accuracy or timeliness of externally hosted materials.

  • NVM GitHub page