Using Node Version Manager (nvm)
nvm is the most widely used tool for managing multiple Node.js versions on Linux. It allows you to install, switch, and uninstall versions seamlessly.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
(or use wget
), then reload your shell configuration with source ~/.bashrc
(or ~/.zshrc
). Verify installation with nvm --version
.nvm install 18.16.0
(replace with desired version).nvm ls
.nvm use 18.16.0
.nvm alias default 18.16.0
.nvm uninstall 18.16.0
..nvmrc
file in your project root with the desired version (e.g., 18.16.0
). Running nvm use
in the directory will automatically switch to the version specified in .nvmrc
.Using n (Node Version Switcher)
n is a lightweight tool for switching between Node.js versions, ideal for users who prefer simplicity. It requires Node.js to be pre-installed.
sudo npm install -g n
to install globally via npm.sudo n latest
.sudo n lts
.sudo n 18.16.0
.n
, then select the version from the interactive list./usr/local/n/versions/node
, and switching versions updates the system-wide Node.js binary.Using asdf
asdf is a generic version manager supporting multiple languages (including Node.js). It’s highly extensible and integrates well with existing shell environments.
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0
echo -e "\n. $HOME/.asdf/asdf.sh" >> ~/.bashrc # For bash
echo -e "\n. $HOME/.asdf/completions/asdf.bash" >> ~/.bashrc
source ~/.bashrc
asdf plugin-add nodejs
.asdf install nodejs 18.16.0
.asdf global nodejs 18.16.0
(sets the default for the system).asdf local nodejs 18.16.0
(creates a .tool-versions
file in the project).asdf list nodejs
.Using Volta
Volta is a modern tool designed for speed and simplicity, with built-in support for Node.js and npm version management. It automatically pins versions per project.
curl https://get.volta.sh | bash
and restart your terminal.volta install node@18.16.0
.volta pin node@18.16.0
(creates a package.json
entry or .volta
file).volta pin node@18.16.0
(updates the user’s default).volta list node
.Using fnm (Fast Node Manager)
fnm is a Rust-based tool optimized for performance, offering fast installation and switching of Node.js versions. It’s ideal for developers who prioritize speed.
curl -fsSL https://fnm.vercel.app/install | bash
. Reload your shell with source ~/.bashrc
(or ~/.zshrc
).fnm install 18.16.0
.fnm use 18.16.0
.fnm default 18.16.0
.fnm list
.