NVM, or Node Version Manager, is an indispensable tool for developers working with Node.js. It allows for seamless switching between different Node.js versions on a single machine, which is crucial for testing compatibility, managing project dependencies, and ensuring a smooth development workflow. While NVM is natively available on macOS and Linux, Windows users have historically faced challenges. However, with the advent of nvm-windows, the process has become remarkably straightforward. This guide will walk you through the essential steps to install and effectively utilize NVM on your Windows system, empowering you to manage your Node.js environments with ease and efficiency.

Understanding the Importance of NVM for Node.js Development
Node.js is a dynamic and rapidly evolving platform. As new versions are released, they often introduce significant changes, performance improvements, and new features. Simultaneously, many projects, especially in enterprise environments or collaborative settings, might be tied to specific, older Node.js versions for stability or compatibility reasons. This divergence creates a common developer scenario: needing to work on multiple projects, each requiring a different Node.js runtime.
Without a version manager like NVM, the typical approach involves manually uninstalling the current Node.js version and installing the desired one. This process is not only time-consuming but also prone to errors. Dependency conflicts can arise, and reverting to a previous version can become a complex and frustrating undertaking.
NVM elegantly solves this problem. It operates by installing Node.js versions in isolated directories and then symlinking the globally used version to a single location. This architecture means that switching between Node.js versions is an instantaneous operation, with no need for reinstallation. Furthermore, NVM facilitates the management of npm (Node Package Manager) packages. When you switch Node.js versions, NVM can also manage the associated npm packages, ensuring that each Node.js environment has its own set of globally installed modules, preventing conflicts between different project requirements.
Key Benefits of Using NVM
- Version Flexibility: Effortlessly switch between any installed Node.js versions. This is vital for testing applications across different runtime environments or when contributing to projects with specific version requirements.
- Dependency Management: Each Node.js version managed by NVM can have its own set of globally installed npm packages. This isolation prevents “dependency hell,” where different projects require incompatible versions of the same package.
- Streamlined Workflow: Reduce the time spent on manual installations and uninstalls. NVM makes it quick and easy to set up a new development environment or to adapt to the requirements of a new project.
- Cross-Platform Consistency: For teams working across different operating systems, using NVM ensures that everyone can operate with the exact same Node.js versions, eliminating a significant source of environmental discrepancies.
- Easier Testing and Debugging: Quickly test your applications with older and newer Node.js versions to identify potential compatibility issues or to benchmark performance improvements.
Installing NVM for Windows
The official NVM project does not directly support Windows. However, a community-driven project called nvm-windows provides a robust and widely adopted solution for managing Node.js versions on Windows. The installation process is designed to be simple and integrates well with the Windows operating system.
Prerequisites
Before proceeding with the installation, ensure that you have uninstalled any existing Node.js installations from your system. Having multiple Node.js installations can lead to conflicts and unexpected behavior. If you have previously installed Node.js via the official installer, it’s crucial to remove it through “Add or Remove Programs” in Windows Settings. Also, ensure that any environment variables related to Node.js are removed.
Step-by-Step Installation Guide
-
Download the Installer:
Navigate to thenvm-windowsreleases page on GitHub. You can typically find this by searching for “nvm-windows GitHub releases.” On the releases page, locate the latest stable release and download thenvm-setup.zipfile from the “Assets” section. -
Extract the Installer:
Once downloaded, extract the contents of thenvm-setup.zipfile. This will typically result in an executable installer file (e.g.,nvm-setup.exe). -
Run the Installer:
Double-click thenvm-setup.exefile to begin the installation process. The installer will guide you through a series of prompts. -
Accept License Agreement:
Review and accept the license agreement. -
Choose Installation Directory:
The installer will prompt you to choose an installation directory for NVM. It’s generally recommended to accept the default location unless you have a specific reason to change it. This directory will store the NVM executable and manage your Node.js installations. -
Choose Node.js Symlink Directory:
The installer will also ask for a directory where Node.js symlinks will be created. This is the location that your system’s PATH will point to, making the currently active Node.js version accessible from the command line. Again, accepting the default is usually the best option. -
Complete Installation:
Follow the on-screen prompts to complete the installation. The installer will add the necessary entries to your system’s PATH environment variable, allowing you to access NVM commands from any command prompt or terminal. -
Verify Installation:
After the installation is complete, open a new Command Prompt or PowerShell window. It’s important to open a new window because existing ones might not have picked up the updated PATH environment variable. Type the following command:nvm versionIf the installation was successful, this command will display the installed version of
nvm-windows.
Managing Node.js Versions with NVM
With NVM for Windows installed, you can now leverage its power to manage your Node.js environments. The core functionality revolves around installing, selecting, and uninstalling different Node.js versions.
Installing Node.js Versions
To install a specific Node.js version, you use the nvm install command followed by the version number.
-
Install Latest LTS (Long-Term Support) Version:
For most projects, it’s recommended to use the latest LTS version for stability.nvm install lts -
Install Latest Current Version:
If you need the newest features and are comfortable with potentially less stable releases, you can install the latest current version.nvm install node -
Install a Specific Version:
To install a particular version (e.g., Node.js 16.14.0), use:nvm install 16.14.0You can also use partial version numbers, and NVM will attempt to find the latest available match (e.g.,
nvm install 18will install the latest Node.js 18.x.x version).
Listing Installed Versions
To see all the Node.js versions you have installed via NVM, use the following command:
nvm list
This command will display a list of installed versions, and the currently active version will be marked with an asterisk (*).

Switching Between Versions
The primary advantage of NVM is the ease of switching between installed Node.js versions. Use the nvm use command followed by the version number.
-
Switch to a Specific Version:
nvm use 16.14.0 -
Switch to the Latest LTS:
nvm use lts -
Switch to the Latest Current:
nvm use node
When you switch versions, NVM will update the symlink to point to the selected Node.js installation. You can verify the change by running node -v and npm -v in a new command prompt window.
Uninstalling Node.js Versions
If you no longer need a specific Node.js version, you can uninstall it using the nvm uninstall command.
nvm uninstall 16.14.0
This command will remove the specified Node.js version and its associated global npm packages.
Advanced NVM Usage and Best Practices
While the core commands for installing and switching versions are straightforward, NVM offers additional functionalities and best practices that can further enhance your development experience.
Setting a Default Node.js Version
When you open a new command prompt, NVM will automatically activate a default Node.js version if one is set. This is incredibly convenient as it ensures your environment is ready without manual intervention.
To set a default version, first install the desired version and then use the nvm alias default command. For example, to set Node.js 18.12.0 as your default:
nvm install 18.12.0
nvm alias default 18.12.0
If you later install a new version and want to make it the default, simply repeat the process:
nvm install 20.0.0
nvm alias default 20.0.0
Managing Global npm Packages
A crucial aspect of using NVM is understanding how global npm packages are handled. Each Node.js version managed by NVM has its own isolated set of global packages. This means that installing a package globally with one Node.js version will not make it available to another version.
-
Installing Global Packages:
After switching to a specific Node.js version usingnvm use, you can install global packages as you normally would:npm install -g <package-name>These packages will only be available when that specific Node.js version is active.
-
Reinstalling Global Packages:
When switching between Node.js versions, you might need to reinstall certain global packages. A common practice is to keep a record of your essential global packages (e.g., in a text file or a script) and reinstall them after switching to a new Node.js version.To list all globally installed packages for the current Node.js version, use:
npm list -g --depth=0You can then pipe this output to a file and use it to reinstall them on another version.
Integrating with IDEs and Editors
Most modern Integrated Development Environments (IDEs) and code editors, such as Visual Studio Code, have built-in support for NVM. They can detect the active Node.js version managed by NVM and use it for running scripts, debugging, and providing language services.
In Visual Studio Code, for instance, you can usually see the currently selected Node.js version in the status bar at the bottom. Clicking on it often provides an option to switch to other installed Node.js versions directly from within the editor, leveraging NVM’s capabilities. Ensure your IDE is configured to use the Node.js interpreter managed by NVM.

Troubleshooting Common Issues
-
nvmcommand not found: This is the most common issue and usually means that NVM was not added to your system’s PATH environment variable correctly, or you are running the command in a terminal that was opened before the PATH was updated. Close and reopen your terminal or command prompt. If the issue persists, re-run the NVM installer or manually add the NVM installation directory to your system’s PATH. -
Incorrect Node.js version being used: After switching versions with
nvm use, always verify the active version by runningnode -vin a new terminal window. If the version is still incorrect, it might indicate an issue with symlinks or PATH configuration. -
Permissions issues: On some Windows configurations, you might encounter permission errors when installing Node.js versions or global packages. Running your command prompt or terminal as an administrator can sometimes resolve these. However, it’s generally better to configure permissions correctly for your user account if possible.
By mastering these aspects of NVM for Windows, you can establish a highly efficient and adaptable Node.js development environment, ready to tackle any project requirement.
