đź’ˇ
Managing multiple Node.js versions doesn’t have to be painful — with NVM, it’s quick, clean, and beginner-friendly.

What is NVM?

NVM stands for Node Version Manager. It’s a command-line tool that lets you install and use multiple Node.js versions on the same computer. If you work across several projects, you’ve probably run into version conflicts — NVM solves that neatly.

Why You Need It

Imagine you’re maintaining one project that needs Node 16 and another that needs Node 20. Without NVM, you’d have to constantly uninstall and reinstall different versions — which is frustrating and error-prone.

With NVM, you simply run one command to switch versions and get back to coding.

Installation

You can install NVM on macOS, Linux, or WSL using a simple terminal command:

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

After installation, restart your terminal and confirm it worked:

nvm --version

If you see a version number, you’re all set!

Switching Node Versions

Once NVM is installed, you can install and switch between versions easily.
Here’s what you’ll typically use:

  • nvm install --lts → Installs the latest long-term support version
  • nvm install 20 → Installs Node 20
  • nvm use 18 → Switches to Node 18
  • nvm alias default 20 → Sets Node 20 as the default
đź§­
Create a .nvmrc file in your project folder (just put the version number inside, like 18) — NVM will automatically pick the right version when you run nvm use.

Keeping Things Organized

As you switch between projects, older Node versions may pile up.
You can check what you have installed with nvm ls, and remove older ones with nvm uninstall 16.

⚠️
If nvm doesn’t seem to work after installation, make sure your terminal’s configuration file (.bashrc, .zshrc, or .profile) includes the NVM script. Restarting your terminal usually fixes it.

Learn More

GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions - nvm-sh/nvm

✨ Quick Recap:

  • Install NVM with a simple command
  • Switch easily between Node.js versions
  • Use .nvmrc for per-project management
  • Keep your setup clean with nvm ls and nvm uninstall