What is NVM?

Node Version Manager (NVM) is a tool used to manage multiple active Node.js versions.

The Node.js platform, Node.js ​community of tools, and Node.js libraries are fast-moving targets – what might work under one Node.js version is not guaranteed to work for another version of Node.js. Hence, users need ways to switch between multiple versions of Node.js

widget

Why use NVM?

NVM allows users to:

  • Locally download any of the remote Long Term Support (LTS) versions of Node.js with a simple command.
  • Easily switch between multiple versions of Node.js, right from the command line.
  • Set up aliases to switch between different downloaded versions of Node.js with ease.

1. Installing NVM

Run the NVM installer using either of the following commands:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

or

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

2. Using NVM

Once NVM is installed it allows users to install any version of Node.js through a simple command:

nvm install <SPECIFIC_NODE_VERSION>

To install the latest version of Node.js, use the following command:

nvm install node

To use any specific version of Node.js for your code, use the following command:

nvm use <SPECIFIC_NODE_VERSION>
Copyright ©2024 Educative, Inc. All rights reserved