NVM (Node Version Manager) lets you install and switch between multiple Node.js versions on a single machine. This is invaluable for development environments where different projects require different Node.js versions. This guide installs NVM on Ubuntu 26.04 LTS.

Tested and valid on:

  • Ubuntu 26.04 LTS

Prerequisites

  • Ubuntu 26.04 LTS
  • A user account (does not require sudo — NVM installs per-user)
  • curl or wget

Step 1 – Install NVM

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

Step 2 – Activate NVM in the Current Shell

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

Or simply close and reopen your terminal — the installer adds these lines to your ~/.bashrc automatically.

Step 3 – Verify NVM Installation

nvm --version

Step 4 – List Available Node.js Versions

nvm ls-remote | tail -20

Step 5 – Install Node.js Versions

nvm install 22          # Install Node.js 22 LTS
nvm install 20          # Install Node.js 20 LTS
nvm install --lts       # Install latest LTS

Step 6 – Switch Between Versions

nvm use 22
node --version
nvm use 20
node --version

Step 7 – Set a Default Version

nvm alias default 22
node --version   # should show v22.x

Step 8 – Use a Specific Version for a Project

Create a .nvmrc file in your project root:

echo '22' > .nvmrc

Then run nvm use in that directory to switch automatically.

Conclusion

NVM is configured on Ubuntu 26.04 LTS. You can now manage multiple Node.js versions effortlessly, ensuring each project runs on its required runtime.