Installing Node.js with Node Version Manager (nvm)
In the world of JavaScript, different projects need different versions of Node.js (and of npm, which comes bundled with it) to run. But switching versions by installing and uninstalling Node.js each time you need something different is not fun.
Enter: Node Version Manager (nvm). nvm lets you keep multiple versions of Node.js installed at the same time, and then swap between them with a single command.
This guide will walk you through installing nvm and one version of Node.js (and npm). After reading this article, you’ll know:
- How to check if Node.js or nvm are already installed
- How to install nvm, the Node Version Manager
- How to use nvm to install a Node.js version
- How to remove a standalone Node.js installation, if you need to
So let’s get started!
Before installing anything, let’s find out what’s already on your computer. Depending on where you’re starting from, your next steps can look a little different.
-
You can find instructions in How to Choose and Open Your First Terminal if you need them!
-
Run
nvm --versionto see if nvm is already installed.If nvm is installed, you’ll see its version number:
Terminal window nvm --versionv2.0.0Next stepWoo! Skip ahead to How Do I Install Node.js?
If you already installed some Node.js versions with nvm follow along anyway to get the latest LTS version.
If it isn’t, you’ll get an error:
Terminal window nvm --version'nvm' is not recognized as an internal or external command, operable program or batch file.If nvm is installed, you’ll see its version number:
Terminal window nvm --version0.40.7Next stepWoo! Skip ahead to How Do I Install Node.js?
If you already installed some Node.js versions with nvm follow along anyway to get the latest LTS version.
If it isn’t, you’ll get an error:
Terminal window nvm --versionzsh: command not found: nvmIf nvm is installed, you’ll see its version number:
Terminal window nvm --version0.40.7Next stepWoo! Skip ahead to How Do I Install Node.js?
If you already installed some Node.js versions with nvm follow along anyway to get the latest LTS version.
If it isn’t, you’ll get an error:
Terminal window nvm --versionbash: nvm: command not found -
Run
node --versionto see if Node.js is already installed.If Node.js is installed, you’ll see its version number:
Terminal window node --versionv24.21.0Next stepMake sure to uninstall it before moving on!
If it isn’t, you’ll get an error, which is good in this case, because it means you’re starting from a clean slate:
Terminal window node --version'node' is not recognized as an internal or external command, operable program or batch file.If Node.js is installed, you’ll see its version number:
Terminal window node --versionv24.21.0If it isn’t, you’ll get an error:
Terminal window node --versionzsh: command not found: nodeIf you saw a version number, nvm will find that Node.js once you install it, and list it as your
systemversion.If Node.js is installed, you’ll see its version number:
Terminal window node --versionv24.21.0If it isn’t, you’ll get an error:
Terminal window node --versionbash: node: command not foundIf you saw a version number, nvm will find that Node.js once you install it, and list it as your
systemversion.
With the checks done, you know exactly where you’re starting from. Next up: getting nvm on your computer!
Time to install nvm itself! As a reminder, nvm (Node Version Manager) is not Node.js: it’s a manager, a separate tool that installs Node.js versions and switches between them for you.
Knowing which tool you’re dealing with is especially important when you’re troubleshooting. There are many ways to manage Node.js versions, and more than one program called “Node Version Manager.” In this guide, you’ll use one of these two:
- On macOS and Linux, nvm-sh.
- On Windows, NVM for Windows.
Coding in WSL on Windows? You’ll need nvm-sh, as explained earlier.
They’re both called nvm, but they’re two distinct tools by different developers. Many of their commands are the same, but the differences can bite you when you least expect it! If you run into trouble, make sure you’re reading the documentation for the right one.
Keep in mind, installing nvm does not install a particular Node.js version for you. nvm is the tool that installs Node.js, not Node.js itself. You will choose and install your first Node.js version (and thus, npm version) in the next section.
NVM for Windows uses a standalone installer.
-
Confirm Node.js is not already installed.
A preexisting Node.js installation can mess with NVM for Windows, so make sure you checked for Node.js and uninstalled it, if necessary.
-
Find the latest release on the NVM for Windows “Releases” page.
The latest version appears towards the top. Make sure to pick a release with a “Latest” label, and not a “Pre-release” one.
-
Under Assets, choose the installer for your computer:
- Most Intel or AMD computers:
nvm-2.x.x-x64-setup.exe - ARM computers:
nvm-2.x.x-arm64-setup.exe
The similarly named
sync.exefiles are not installers. - Most Intel or AMD computers:
-
With version 2 and above you don’t need to run the installer as Administrator. In fact, if you run it as Administrator, you might run into issues!
You might still see a Windows permission prompt during the installation. That’s expected, so go ahead and select Yes.
-
Accept the defaults and complete the installation.
On macOS, nvm provides a script you can run to install it.
-
Install Apple’s command line tools.
The install script needs them, and new Macs don’t come with them. Run:
Terminal window xcode-select --installFollow the prompts in the window that opens.
If the tools are already installed, the terminal tells you so, and you can safely move on.
-
Run nvm’s official install script.
Terminal window curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh | bashIf you’re curious, here’s a breakdown of what this command does:
- Uses
curl, a common terminal tool for downloading content from the web, to download the installation script from nvm’s GitHub repository. - Uses the
|character, called a pipe, to take the result of the command on the left and hand it over to the command on the right to use as its input. - Uses
bashto actually run the script we piped through, which installs nvm.
- Uses
On Linux, nvm provides a script you can run to install it.
-
Run nvm’s official install script.
You can use either
curlorwget, depending on what’s available on your Linux distribution.Terminal window curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh | bashIf
curlis unavailable, usewget:Terminal window wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh | bashIf you’re curious, here’s a breakdown of what these commands do:
- Uses
curlorwget, common terminal tools for downloading content from the web, to download the installation script from nvm’s GitHub repository. - Uses the
|character, called a pipe, to take the result of the command on the left and hand it to the command on the right as input. - Uses
bashto actually run the script we piped through, which installs nvm.
- Uses
Now that you’re done with the installation, confirm nvm has been installed correctly:
-
If you already had a terminal open while installing nvm, it might not automatically register the new installation. Close it, then open a new one.
-
Run
nvm --versionto see if nvm has been installed.If nvm is installed correctly, your terminal responds with the version you have:
Terminal window nvm --versionv2.0.0Congratulations! 🎉 nvm is ready to go.
If nvm is installed correctly, your terminal responds with the version you have:
Terminal window nvm --version0.40.7Congratulations! 🎉 nvm is ready to go.
If nvm is installed correctly, your terminal responds with the version you have:
Terminal window nvm --version0.40.7Congratulations! 🎉 nvm is ready to go.
If the command prints output like the example, congratulations! 🎉
With nvm installed, you’re ready for the main event: Node.js itself! Remember, nvm doesn’t come with a Node.js version by default, but it can install any version you want. In this guide we’ll show you how to install the most recent version labeled “long-term support,” or “LTS” for short.
-
With version 2 and above of NVM for Windows, when you run the install command nvm automatically switches the active version to the version it just installed:
Terminal window nvm install lts⠹ Installing 1 version: Extracting... 4sNow using Node.js v24.21.0 by default.Installed 1 version: 24.21.0Completed in 7sIf
nvmisn’t recognized, go back to Check That nvm Was Installed.
-
When you run the install command nvm automatically switches the active version to the version it just installed:
Terminal window nvm install --ltsInstalling latest LTS version.Downloading and installing node v24.21.0...Now using node v24.21.0 (npm v11.19.0)If
nvmisn’t found, go back to Check That nvm Was Installed.
-
When you run the install command nvm automatically switches the active version to the version it just installed:
Terminal window nvm install --ltsInstalling latest LTS version.Downloading and installing node v24.21.0...Now using node v24.21.0 (npm v11.19.0)Creating default alias: default -> lts/* (-> v24.21.0 *)If
nvmisn’t found, go back to Check That nvm Was Installed.
Remember how npm comes bundled with Node.js? That means you just installed npm too! From now on, whenever you switch Node.js versions with nvm, npm switches right along with it.
Let’s make sure both programs were installed correctly.
To check that Node.js is correctly installed, run:
node --versionv24.21.0
To check that npm was installed alongside Node.js, run:
npm --version11.19.0
Both commands should output a version number. Node.js and npm are separate programs, so their version numbers differ!
If you’re here, you probably found a standalone Node.js installation while checking what’s already installed, and you need to remove it before installing nvm. On Windows this step is a must. On macOS and Linux, it’s only needed if you run into weird issues or really want a clean setup.
To uninstall Node.js you should use the same method you used to install it in the first place. We’ll try to cover the most common (un)installation methods.
Node.js can be removed like any other program.
- Open Settings.
- Select Apps, then Installed apps.
- Find Node.js.
- Select Uninstall and follow the prompts.
The exact path through Settings varies between Windows versions. If yours looks different, follow the official Microsoft guide for uninstalling programs.
If you’re a Chocolatey user, you can run choco list and see if nodejs or
nodejs-lts appears on the package list.
To uninstall:
-
Open a terminal as Administrator.
-
Run the uninstall command that matches the package in your list.
If the package is
nodejs, run:Terminal window choco uninstall nodejsIf the package is
nodejs-lts, run:Terminal window choco uninstall nodejs-lts
If you’re a Homebrew user, you can run brew list and see if node or
node@XX appears on the list. In node@XX, XX is the major version number.
-
Terminal window brew uninstall nodeIf you installed a versioned formula use this command instead:
Terminal window brew uninstall node@XXReplace
XXwith the version number shown bybrew list. For example, runbrew uninstall node@22to removenode@22.
If you installed Node.js with a .pkg file from the
official Node.js website you’ll need to manually remove
the relevant files and folders from your system.
If you installed Node.js through your distribution’s package manager, remove it with that same manager.
For example, on Ubuntu or Debian:
If you used a different method, follow that method’s removal instructions or manually remove the relevant files and folders from your system.
After uninstalling, open a new terminal and run node --version. If you see
the error from earlier
saying node is not recognized or not found, you did it!
All clean! Now you’re ready to head back to How Do I Install nvm?
Congratulations! You’ve done it! 💫 You’re now in possession of nvm, Node.js, and npm, some of the most powerful tools in your coding journey. A whole new world of possibilities has opened up before you!
Choose where to go next:
- To start having fun with Node.js and npm, try:
- To learn the context for these tools, read: