Switch Node versions in the terminal with a single command
When projects require different Node versions, you can switch to the desired version immediately by typing one line in the terminal. This approach involves installing multiple versions simultaneously and using them only when needed. nvm is a version management tool for Node.js that operates as a script directly within the shell environment.
The actual flow of version switching
Typing nvm install 24 installs the latest Node 24 version, while typing nvm use 22 switches to version 22 immediately. This process does not affect the system's default Node installation and operates only within the user account. Since each shell session manages versions independently, it is possible to use version 20 in one terminal and version 22 in another.
Project-specific version pinning and LTS support
Placing a .nvmrc file in a project folder automatically activates the specified version when you navigate to that folder. This is a standard method to help team members work with the same Node version. Long-term support (LTS) versions can also be easily referenced using aliases such as lts/* or lts/argon.
Installation environment and requirements
nvm works in POSIX-compatible shells including bash, zsh, sh, dash, and ksh, and supports Unix, macOS, and Windows WSL environments. Running the installation script clones the repository to the ~/.nvm directory and adds an auto-load setting to the shell profile file. On macOS, Xcode command line tools are required, and on Linux, a C++ compiler may be required for source builds. Fish shell is not officially supported, and on Windows, it must be used via WSL or Git Bash.
Pre-use checks
Because nvm is a user-level tool, mixing it with a system-wide Node installation can cause version mismatches. If you previously installed global packages using sudo, you should install them with npm install -g without sudo when using nvm. If the ~/.npmrc file contains a prefix setting, it will conflict with nvm and must be removed. nvm installation via Homebrew is not officially supported, so if it was previously installed, it should be removed and reinstalled using the official script.