Managing Node.js Versions with NVM
Install nvm, run Node 26 LTS alongside other versions, switch per project with a .nvmrc file, and set a default version.

Different projects need different versions of Node.js. One app runs on Node 24, a new one needs Node 26, and reinstalling Node every time you switch projects is slow and error prone.
Node Version Manager, or nvm, fixes that. It installs several versions of Node side by side and lets you switch between them with one command. This post covers Mac and Linux with nvm, and Windows with the separate nvm-windows tool.
By the end you will be able to install nvm, install two versions of Node, switch between them, and pin a version to a project so the switch happens on its own.
Prerequisites
Do this before you install anything.
- Uninstall any existing Node.js installation first. If Node was installed from nodejs.org or a package manager, remove it before you start, on Mac, Linux and Windows. Leaving it in place is the most common cause of the wrong version showing up later.
- You need a terminal on Mac or Linux, and administrator rights on Windows.
- Check what you have now, if anything:
node -v
npm -v
which node
If those commands find a Node that did not come from nvm, uninstall it, then continue.
Install nvm on Mac and Linux
Install nvm with the official install script from the nvm-sh project. Check the version in the URL before you run it, and only use the script from that repository. Do not paste an install script from a random page.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash
The script adds nvm to your shell profile. Your current terminal will not pick that up on its own, so either open a new terminal or load nvm into this one:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
Skipping this step is the usual cause of nvm: command not found right after install.
Verify the install
nvm --version
You should see 0.40.8. If the command is still not found, close the terminal, open a new one, and try again. If it still fails, check that the lines above were added to your shell profile file, .zshrc on newer Macs or .bashrc on most Linux systems.
Install Node
Install the Long Term Support release first. LTS versions are the stable line that projects should run on. As of this revision, Node 26 is the Active LTS line, supported until Apr 30, 2029, and Node 24 and Node 22 are Maintenance LTS.
nvm install --lts
Do not start with nvm install latest. That installs the newest Current release, which gets new features first and is only supported for a short time. Use Current to test upcoming features, not for real projects.
Install a second version as well, so you can practise switching. Node 24 is a good second line to keep:
nvm install 24
Verify both:
node -v
npm -v
List, switch and set a default
See what is installed:
nvm ls
See what you could install, LTS only:
nvm ls-remote --lts
Check which version the current shell is using:
nvm current
Switch the current shell to Node 24, then back to Node 26:
nvm use 24
node -v
nvm use 26
node -v
nvm use only changes the current shell. It does not change what a new terminal starts with.
To set what every new shell starts with, set the default alias:
nvm alias default 26
Open a new terminal and run node -v to confirm it starts on Node 26.
Pin a project with .nvmrc
Remembering version numbers for every project does not scale. Put the version in the project instead, in a file named .nvmrc in the project root:
echo "26" > .nvmrc
Commit that file with the project. Anyone who clones it then runs, from the project folder:
nvm install
nvm use
With no version named, nvm install installs the version listed in .nvmrc, and nvm use switches the current shell to it. That is the workflow to use day to day: one file per project, two commands, no version numbers to remember.
Windows with nvm-windows
Windows does not use nvm. It uses nvm-windows, a separate tool with a similar name and similar commands. Do not follow the Mac and Linux steps above on Windows.
- Uninstall any existing Node.js installation first.
- Download the nvm-windows installer,
nvm-setup.exe, from the nvm-windows releases page on GitHub. - Run the installer as administrator, then open a new terminal.
The basic commands match:
nvm install 26
nvm use 26
nvm list
node -v
The differences matter. There is no nvm alias default that works the same way, so set the version with nvm use in each new terminal. Support for .nvmrc is limited, so do not rely on it on Windows the way you can on Mac and Linux. Check the nvm-windows documentation for the version you installed if a command behaves differently.
Keep versions tidy
Global packages are installed per Node version. A tool you installed globally under Node 24 will not be there under Node 26. Carry your global packages over when you install a new version:
nvm install 26 --reinstall-packages-from=24
Remove a version you no longer need:
nvm uninstall 24
Run nvm ls first and confirm the version number. Uninstalling the version your current shell is using will break that shell until you run nvm use with another version.
To update nvm itself on Mac and Linux, run the install script again with the newer version number in the URL. It updates nvm in place and keeps your installed Node versions.
Troubleshooting
nvm: command not found after install
Open a new terminal, or load nvm into the current one with the two lines in the install section. If it still fails, check that those lines are in your shell profile.
node -v shows the wrong version
You probably have two installs. Run which node. If the path does not point inside your .nvm folder, an older install is still on the system. Uninstall it, open a new terminal, and check again.
A global package disappeared after switching
That is expected. Global packages belong to one Node version. Switch back with nvm use, or reinstall the package under the new version, or reinstall the new version with --reinstall-packages-from as shown above.
A project breaks after you open a new terminal
The new terminal started on your default version, not the project version. Go to the project folder and run nvm use, which reads .nvmrc. If there is no .nvmrc, add one.
Checklist
- Uninstall any existing Node before you install nvm or nvm-windows.
- Install nvm from the official nvm-sh script, then reload your shell.
- Verify with
nvm --versionbefore you install Node. - Install LTS first with
nvm install --lts, notlatest. - Use
nvm usefor the current shell andnvm alias defaultfor new shells. - Add a
.nvmrcfile to every project and commit it. - Carry global packages over with
--reinstall-packages-fromwhen you add a version.
Set this up once per project and version switching stops being a task. Open the project, run nvm use, and start work.
About the author
- I am an Engineer in love with software and writing code. I am super passionate about the reach of technology, and when it comes to conquering new frontiers, I want to be there in the forefront.



