Managing multiple Node.js versions can become challenging when different projects require different environments. This is where NVM (Node Version Manager) becomes one of the most valuable tools for Node.js developers.
What Is NVM?
NVM stands for Node Version Manager. It is a command-line tool that enables developers to install and manage multiple versions of Node.js on the same computer.
Instead of uninstalling and reinstalling Node.js every time a project requires a different version, NVM lets you switch versions instantly.
Example Scenario
Project A requires Node.js 18.
Project B requires Node.js 20.
Project C requires Node.js 22.
With NVM, switching between versions takes only a few seconds.
Why Every Node.js Developer Should Use NVM
- Manage multiple Node.js versions
- Test applications across versions
- Avoid compatibility issues
- Upgrade and downgrade safely
- Keep development environments organized
- Work on legacy and modern projects simultaneously
Install NVM on Windows
Windows users can install NVM for Windows.
- Download NVM for Windows.
- Run the installer.
- Complete the setup wizard.
- Restart Command Prompt or PowerShell.
Verify installation:
nvm version
Install NVM on Linux and macOS
Open Terminal and run:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
Reload terminal:
source ~/.bashrc
Verify installation:
nvm --version
Install a Node.js Version
Install the latest version:
nvm install node
Install the latest LTS version:
nvm install --lts
Install a specific version:
nvm install 20.18.0
View Installed Versions
nvm list
This command displays all Node.js versions currently installed on your machine.
Switch Between Versions
To use Node.js version 20:
nvm use 20
Verify active version:
node -v
Set a Default Version
Configure a version that loads automatically whenever you open a terminal:
nvm alias default 20
Verify:
nvm current
Upgrade Node.js Using NVM
Install the newest LTS release:
nvm install --lts
Switch to the new version:
nvm use --lts
Downgrade Node.js Using NVM
Need an older version for a legacy project?
nvm install 18
nvm use 18
This makes downgrading safe and reversible.
Use .nvmrc for Team Projects
Professional development teams often create a file named:
.nvmrc
Example:
20.18.0
Developers can automatically switch versions:
nvm use
Remove Unused Versions
Delete older versions you no longer need:
nvm uninstall 16
This helps free up disk space and keeps your environment organized.
Common NVM Commands
| Command | Purpose |
|---|---|
| nvm install node | Install latest Node.js |
| nvm install --lts | Install latest LTS |
| nvm list | Show installed versions |
| nvm use 20 | Switch version |
| nvm current | Show active version |
| nvm uninstall 18 | Remove version |
| nvm alias default 20 | Set default version |
Best Practices for Using NVM
- Always use LTS versions in production.
- Create .nvmrc files for projects.
- Keep multiple versions only when necessary.
- Test applications before upgrading.
- Remove unused versions periodically.
- Document required Node.js versions in project documentation.
Frequently Asked Questions
Conclusion
NVM is one of the most useful tools in the Node.js ecosystem. Whether you're maintaining legacy applications, testing compatibility, or developing modern web applications, NVM makes Node.js version management simple and efficient.
By mastering NVM, you'll save time, avoid version conflicts, and maintain cleaner development environments across all your projects.
About ShasTech-IT
ShasTech-IT specializes in Node.js development, web application development, Android apps, ERP, HRMS, WMS, POS systems, e-commerce solutions, and custom business software development.