Linux & DevOps Ubuntu 24.04 LTS

Managing Multiple Node.js Versions on Linux Using NVM

Learn how to install and manage Node.js versions on Linux with NVM, setting project defaults and avoiding npm permission issues.
Z
Zaisha
Staff Writer · Verified Editor
Published Oct 22, 2026 · 3 min read · 197 words
Quick Overview

This deep-dive covers manage node versions nvm with actionable analysis, practical implications, and expert insights.

Managing Multiple Node.js Versions on Linux Using NVM

Why Avoid System Node Packages?

Installing Node.js via sudo apt install nodejs locks you into an outdated distribution version and forces you to run global npm commands as root. Node Version Manager (NVM) installs Node runtimes entirely within your user home directory, enabling smooth version switching without permission errors.

Step 1: Installing NVM on Ubuntu

Run the official NVM install script from GitHub:

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

Source your shell configuration or open a new terminal window:

source ~/.bashrc
# Or if using zsh: source ~/.zshrc

Step 2: Installing Specific Node.js Versions

Install the latest Long-Term Support (LTS) release alongside the latest current release:

# Install current LTS (e.g. Node 20.x)
nvm install --lts

# Install latest release (e.g. Node 22.x)
nvm install 22

# Verify installed versions
nvm ls

Step 3: Switching Active Versions

Switch between versions on the fly:

nvm use 20
node -v

nvm use 22
node -v

Step 4: Using .nvmrc for Team Consistency

To ensure all team members use the identical Node version, create an .nvmrc file in your repository root:

echo "20" > .nvmrc
nvm use

Global npm packages installed with NVM are isolated per Node version and never require root permissions.

Tested & Verified Environment
Author Verified
Operating System: Ubuntu 24.04 LTS
Verification Date: Oct 22, 2026
Testing Methodology & Notes: Tested on Ubuntu 24.04 LTS with NVM v0.40.1. Installed Node v20.18 (LTS) and Node v22.11. Switched versions and verified npm prefix points inside user home directory.

Was this technical analysis helpful?

Your feedback informs our benchmark updates and ongoing article audits.

✓ Thank you for your feedback! Our editorial engineers review submissions weekly.

Frequently Asked Questions

Structured for search engines and AI answer systems (AEO/GEO).

System packages often ship older versions and place global packages into /usr/lib/node_modules, requiring sudo to install npm packages globally.

Place an .nvmrc file in your project root containing the version number (e.g. 20), then run nvm use in that folder.

Run nvm alias default 20 to set Node 20 as your persistent default.

More answers in our FAQ hub.

Z
Zaisha

Tech journalist covering AI, software, and emerging technology with a focus on practical insights.

Testing Standards: Tutorials and guides are hands-on tested on Ubuntu Linux workstations before release.
View all articles by Zaisha

Practical Linux & Applied AI Newsletter

Get new tested tutorials and benchmark comparisons delivered directly to your inbox. Zero spam.

Join Weekly guides readers getting our weekly digest.

  • Practical Linux administration & terminal workflows
  • Tested open-source AI setups & benchmarks
  • Zero spam - unsubscribe anytime

Join Weekly guides readers · Weekly digest · Unsubscribe anytime. RSS

Continue Exploring