Why You Need NVM: 5 Reasons Every Node.js Developer Should Use It

2024/11/09 2026/05/16
Why You Need NVM: 5 Reasons Every Node.js Developer Should Use It

Why should you use NVM? If you work on more than one Node.js project, NVM (Node Version Manager) eliminates the pain of juggling incompatible Node.js versions, permission headaches, and broken global packages. In real-world development, you rarely start fresh — you maintain existing codebases that each demand a specific Node.js version. NVM lets you install and switch between any number of Node.js versions instantly, keeping every project running smoothly on the right runtime.

If you are not yet familiar with what NVM is, check out What Is NVM for a quick introduction, or see NVM vs NPM vs Node.js to understand how these tools relate to each other.

The Problem: Why You Can’t Just Install Node.js Directly

Installing Node.js directly from the official website works fine when you only have one project. But professional development rarely stays that simple. Here is what happens in reality:

  • Your company has a legacy application locked to Node.js 16, a main product on Node.js 20, and a new microservice targeting Node.js 22.
  • You join an open-source project that requires a different Node.js version than your day job.
  • A dependency upgrade forces you to test against multiple Node.js versions before merging.

Without NVM, switching between versions means uninstalling Node.js, downloading a different installer, running it, and hoping your global packages still work. That process is slow, error-prone, and disruptive. NVM removes all of that friction by letting multiple versions coexist on the same machine.

Reason 1: Version Conflicts Between Projects

This is the most common reason developers adopt NVM. Different projects depend on different Node.js versions and their associated native modules. If you only have one system-wide Node.js installation, you face a choice: break the old project or block the new one.

With NVM, you solve this in seconds:

# Switch to Node.js 18 for your legacy project
nvm use 18

# Switch to Node.js 22 for your new project
nvm use 22

Each version maintains its own node_modules path and global packages. There is no cross-contamination. Your Angular 15 app on Node 18 and your Next.js 14 app on Node 22 coexist peacefully.

Real scenario: Suppose you maintain a client project built with Angular 15 (requires Node.js 18) and your own side project uses the latest Node.js 22 features. Without NVM, you would need to uninstall and reinstall Node.js every time you switch contexts. With NVM, it is a single command that takes less than a second.

Reason 2: No More Permission Errors

When you install Node.js directly on macOS or Linux, the default installation location often requires root privileges. This leads to the dreaded EACCES permission error whenever you try to install a global package:

# Without NVM - permission denied
npm install -g typescript
# Error: EACCES: permission denied

# The dangerous "fix" people resort to
sudo npm install -g typescript  # Don't do this!

Using sudo with npm is a security risk and can corrupt your file permissions. NVM avoids this entirely because it installs Node.js in your home directory (~/.nvm/). Every version, every global package — all owned by your user account. No sudo needed, ever.

# With NVM - just works
nvm use 20
npm install -g typescript  # No sudo, no errors

This alone saves hours of debugging permission issues, especially for developers new to macOS or Linux.

Reason 3: Easy Version Testing

When you maintain a library or an application that needs to support multiple Node.js versions, testing across versions is essential. NVM makes this trivial:

# Test your package across three versions
nvm use 18 && npm test
nvm use 20 && npm test
nvm use 22 && npm test

You can even automate this in a simple shell script:

#!/bin/bash
for version in 18 20 22; do
  echo "Testing on Node.js $version..."
  nvm use $version
  npm test
  if [ $? -ne 0 ]; then
    echo "FAILED on Node.js $version"
    exit 1
  fi
done
echo "All versions passed!"

Without NVM, this kind of multi-version testing requires Docker containers or CI-only workflows. NVM lets you do it locally in seconds, catching compatibility issues before they reach your CI pipeline.

Reason 4: Team Consistency with .nvmrc

One of the most underrated NVM features is the .nvmrc file. Place this file in your project root with a version number, and every team member can instantly match the correct Node.js version:

# Create .nvmrc in your project root
echo "20" > .nvmrc

# Any team member can now run:
nvm use
# Found '/path/to/project/.nvmrc' with version <20>
# Now using node v20.x.x

This eliminates the “it works on my machine” problem caused by version differences. Combined with your project’s package.json engines field, .nvmrc ensures everyone on the team runs the same runtime.

Pro tip: You can configure your shell to automatically run nvm use when you cd into a directory containing an .nvmrc file. This means you never even have to think about switching versions — it happens automatically as you move between projects.

Reason 5: Painless Upgrades

Node.js releases new major versions every six months. When it is time to upgrade, NVM makes the process safe and reversible:

# Install the new version alongside your current one
nvm install 22

# Try it out
nvm use 22
node --version  # v22.x.x
npm test        # Run your tests

# If something breaks, instantly roll back
nvm use 20
# Back to safety in under a second

Compare this to upgrading a system-wide Node.js installation: you download the new installer, run it (overwriting the old version), discover something is broken, then scramble to find the old installer to downgrade. With NVM, the old version is still there, untouched, ready to use.

You can also migrate your global packages when upgrading:

# Install Node 22 and bring along all global packages from Node 20
nvm install 22 --reinstall-packages-from=20

This copies packages like typescript, eslint, and nodemon to the new version automatically.

Getting Started

Ready to start using NVM? Installation takes less than a minute.

On macOS or Linux:

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

After installation, restart your terminal and verify:

nvm --version
# 0.40.1

# Install your first Node.js version
nvm install 22

# Set it as default
nvm alias default 22

On Windows, use nvm-windows, which provides the same core functionality with a Windows-native installer.

Essential commands to know:

CommandWhat it does
nvm install 22Install Node.js 22
nvm use 20Switch to Node.js 20
nvm lsList installed versions
nvm alias default 22Set default version
nvm currentShow active version

Once NVM is installed, there is no reason to ever install Node.js directly again. Every version you need lives under ~/.nvm, isolated and instantly accessible.

Stop fighting version conflicts. Stop using sudo with npm. Stop manually reinstalling Node.js. Install NVM once and solve all of these problems permanently. Your future self — and your teammates — will thank you.

Further reading:

B
BenZ Software Developer

Software developer passionate about technology. Sharing programming experiences and learning notes.