Node Version Manager – NVM
Say goodbye to the "uninstall → reinstall" node loop! Let's use NVM to manage our node versions
NVM: The Ultimate Node.js Version Manager
Introduction
Hey developers! Managing different Node.js versions across projects can be challenging. Instead of constantly uninstalling and reinstalling Node.js, let me introduce you to NVM — the perfect solution for version management!
What is NVM?
Node Version Manager (NVM) is an essential tool for managing Node.js environments that offers:
- 🚀 Instant switching between Node.js versions
- ⚡ Side-by-side installation of multiple versions
- 🔄 Automatic npm version synchronization per project
- 🛠️ Project-specific version management
Say goodbye to the "uninstall → reinstall" loop!
Windows Installation Guide
Pre-Installation Steps
- Remove Existing Node.js
- Uninstall current Node.js installation
- Delete remaining directories (e.g.,
C:\Program Files odejs
) - ⚠️ Important: Remove all Node.js installations as NVM's symbolic links cannot coexist with them
Installation Process
-
Download NVM
- Visit nvm-windows-releases
- Download the latest
nvm-setup.exe
-
Installation Configuration
- Choose custom installation path (recommended:
D: vm
) - Set Node.js symlink location (e.g.,
D: vm4w
) - 🚫 Avoid system directories like Program Files
- Choose custom installation path (recommended:
-
Verify Installation
bashnvm version
A version number indicates successful installation.
Essential Commands
Command | Description | Example |
---|---|---|
nvm list available |
Display installable versions | nvm list available |
nvm install <version> |
Install specific version | nvm install 16.14.2 |
nvm use <version> |
Switch to version | nvm use 18.12.1 |
nvm ls |
List installed versions | nvm ls |
Pro Tips
Project-Specific Version Management
Create a .nvmrc
file in your project root:
bash
# .nvmrc
14.19.0
Then simply run nvm use
in the project directory.
Speed Up Downloads
Configure mirrors for faster installation:
bash
nvm node_mirror https://npmmirror.com/mirrors/node/
nvm npm_mirror https://npmmirror.com/mirrors/npm/
Version Switching Example
bash
# Install LTS version
nvm install 20.11.1
# Activate version
nvm use 20.11.1
# Verify environment
node -v # Output: v20.11.1
npm -v # Auto-matched npm version
Troubleshooting
Common issues and solutions:
-
Version Switch Fails
- Solution: Run terminal as Administrator
-
Command Not Recognized
- Solution: Verify NVM path in system environment variables
Why Choose NVM?
- ⏱️ Time Efficiency: Switch environments in seconds
- 🧩 Project Isolation: Maintain clean environments per project
- 🔄 Team Synchronization: Ensure version consistency across team
- 🧪 Testing Flexibility: Easily test across Node.js versions
