NVM Installed: Managing and Switching Node.js Versions
Node Version Manager (NVM) is one of the most useful tools for any JavaScript or backend developer. It allows you to install, switch, and manage multiple Node.js versions on the same machine without conflicts. If you’ve ever run into “works on my machine” issues or maintained several projects requiring different Node versions, NVM solves that problem cleanly.
Below is an improved and expanded guide with clearer explanations, updated tips, and practical examples.
1. Check Installed Node Versions
To check which Node.js versions are currently installed on your system:
nvm listTo check which versions are available remotely:
nvm ls-remoteUseful for finding long-term support (LTS) releases or older versions required by legacy apps.
2. Install a New Node.js Version
Install a specific version:
nvm install 18.20.4Install the latest LTS version:
nvm install --ltsInstall the latest version overall:
nvm install latestPro tip
You can also install from a specific release line, for example:
nvm install 20This installs the most recent 20.x.x release.
3. Switch Between Node Versions
Make a version active in the current terminal session:
nvm use 20.17.0Confirm the version currently in use:
node -vIf your shell opens a new tab or window, you must run nvm use again or set a default.
4. Set a Default Node.js Version
To automatically load a specific Node.js version every time your terminal opens:
nvm alias default 18.20.4To see all aliases:
nvm alias5. Uninstall Node.js Versions You No Longer Need
Remove an installed version:
nvm uninstall 12.22.1This cleans up space and keeps your NVM environment tidy.
6. Overview of Useful NVM Commands
| Command | Description |
|---|---|
nvm install latest | Install newest Node.js version |
nvm install --lts | Install newest LTS release |
nvm ls | List installed versions |
nvm ls-remote | List all available versions |
nvm alias default | Set a default version |
nvm uninstall | Uninstall a version |
nvm current | Show currently active version |
7. Troubleshooting NVM
NVM command not found
Make sure your shell config contains NVM initialization lines.
For zsh (.zshrc):
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"Node still showing older version
Your shell might be caching paths. Run:
hash -ror simply restart the terminal.
Running NVM in scripts
NVM only loads inside interactive shells unless explicitly sourced:
source ~/.nvm/nvm.sh
nvm use 188. Why Developers Love NVM
- Test apps across multiple Node versions
- Avoid breaking global dependencies
- Keep legacy and modern projects working side-by-side
- Easily switch between environments
- Lightweight and works on macOS, Linux, and WSL
NVM is especially useful when upgrading frameworks like Next.js, NestJS, Express, or tools like Vite, which often require specific Node versions.
Final Notes
This guide is updated for NVM v0.39+ and supports installation of Node.js versions up to 22+.
Happy coding!