4Geeks chosen to deliver AI education in the Bahamas alongside Harvard, Oxford, and Columbia.See more

How to Install NVM on Linux (Ubuntu and CentOS)

By 4Geeks

Install nvm with one script and no sudo, add Node.js 26 LTS and choose the version every terminal starts with.

6 min readLast updated
NVM icon

How do I install NVM on Linux?

Short answer: Run the official script with curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash, then run source ~/.bashrc or open a new terminal. Check it with command -v nvm, install Node.js with nvm install --lts and switch versions with nvm use. It works the same on Ubuntu, Debian, Fedora, Arch and WSL, and you never need sudo.

nvm is a script that lives in your user folder (~/.nvm). It installs each Node.js version there too, so it does not touch the Node.js of your distribution and you can install global npm packages without sudo. The latest version is 0.41.0, from November 4, 2026.

On Ubuntu: install nvm with the script, load it, install Node.js 26 LTS and 24, and set the default version.

nvm on Linux at a glance

What you wantCommand
Install nvmThe official script (step 2)
Load it in the current terminalsource ~/.bashrc
Check that it is installedcommand -v nvm
Install the latest LTSnvm install --lts
Install a specific versionnvm install 24
Switch versionnvm use 24
Set the default versionnvm alias default 26
List installed and available versionsnvm ls and nvm ls-remote --lts
Update npm to its latest versionnvm install-latest-npm

Step 1: install curl

The script downloads with curl or wget. If you do not have either:

bash
sudo apt update && sudo apt install curl    # Ubuntu and Debian
sudo dnf install curl                       # Fedora

This is the only step that uses sudo.

Step 2: run the install script

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

Or with wget:

bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash

The script clones nvm into ~/.nvm and adds these lines to your profile file, usually ~/.bashrc:

bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

The same command updates nvm later: run it again with the new version number.

Step 3: load nvm and check it

The terminal you have open does not know nvm yet. Load it, or open a new terminal:

bash
source ~/.bashrc
command -v nvm

If it prints nvm, it is ready. Use command -v and not which: nvm is a shell function, so which nvm prints nothing even when it works. If you use zsh, load ~/.zshrc instead.

Step 4: install Node.js and switch versions

bash
nvm install --lts
nvm install 24
nvm ls

nvm install --lts installs Node.js 26, the current LTS. To switch, and to choose the version every new terminal starts with:

bash
nvm use 24
node -v
nvm alias default 26

nvm use only changes the current terminal. nvm alias default is what makes the choice stick.

Install nvm on WSL

In WSL (Windows Subsystem for Linux), open your Ubuntu terminal and follow the same steps. Install nvm inside WSL, not NVM for Windows, and keep your projects inside the Linux file system (~/projects), not in /mnt/c, so npm runs faster.

Career · AI Engineering for Developers

Node.js is ready, now build AI apps with it

Use the coding skills you already have to build AI agents, RAG systems and LLM-powered apps, with mentors and real projects.

Install NVM on Linux with AI

An AI assistant such as ChatGPT, Claude or GitHub Copilot can check your shell configuration and read errors for you. These three prompts are ready to copy.

1. Adapt the steps to your distribution

I use [Ubuntu 24.04 / Debian 13 / Fedora 43 / WSL with Ubuntu] and my shell is [bash / zsh].
I want to install nvm 0.41.0 and Node.js 26 LTS, and keep Node 24 for an old project.
[I already have / I don't have] Node.js installed with apt.
Give me the commands one by one and how to check that each one worked.

2. Fix "nvm: command not found"

I ran the nvm install script, but a new terminal says "nvm: command not found".
My shell is [bash / zsh]. This is the end of my [~/.bashrc / ~/.zshrc]:
[paste the last 15 lines]
Tell me what is missing and how to fix it.

3. Clean up an old Node.js

Before nvm, I installed Node.js with [apt / snap / the NodeSource repository].
node -v shows [v18.19.1] and which -a node shows: [paste it]
Tell me whether to remove it and how, so the nvm versions come first.

Read every command before you run it, especially the ones that use sudo or remove packages.

Use .nvmrc to fix the Node.js version of a project

Save the version a project needs in an .nvmrc file and commit it to the repository:

bash
cd ~/projects/my-app
node -v > .nvmrc
nvm use

nvm use with no version reads .nvmrc, and nvm install installs that version if it is missing. To install a new version and bring your global packages with you:

bash
nvm install 26 --reinstall-packages-from=24

When you no longer need a version, remove it with nvm uninstall 22.

Learn with a mentor

From managing versions to shipping AI features

In the 4Geeks AI Engineering for Developers program you add AI agents, RAG and production LLM apps to your portfolio.

Common errors with NVM on Linux

What you seeWhy it happensFix
nvm: command not foundThe terminal has not loaded nvm, or the lines went to another profile fileRun source ~/.bashrc or open a new terminal. If the lines are missing, add them to the file your shell reads and reload it
which nvm prints nothingnvm is a shell function, not a programUse command -v nvm to check it
curl: command not foundcurl is not installedsudo apt install curl on Ubuntu and Debian, sudo dnf install curl on Fedora
node -v shows the distribution's versionA Node.js installed with apt or snap comes firstRun nvm use or nvm alias default 26, and remove the old Node.js if you do not need it
Each new terminal goes back to another versionNo default version is setRun nvm alias default 26
EACCES: permission denied with npm install -gYou are using a Node.js installed with sudoUse a Node.js installed with nvm and never run npm with sudo
Free download

Every NVM command in a 2-page cheat sheet

How to install NVM on Windows, macOS and Linux, the everyday commands side by side, which Node.js version to pick, the most common errors and prompts for ChatGPT, Claude or Copilot. Free, in PDF.

NVM cheat sheet: Windows, macOS and Linux

2 pages · PDF · 4Geeks

  • The install commands for Windows, macOS, Linux and WSL
  • nvm and NVM for Windows commands side by side
  • The 5 most common errors and prompts to fix them with AI

Get it free

Your PDF right away

Frequently asked questions about NVM on Linux

Want to go from setting up Node.js to building AI apps, with real projects and mentors?

See the AI Engineering for Developers program