How to Use nvm: The Beginner's Guide (2026)
CodexFuse Team · 2026-10-31T03:57:27.257Z · 13 min read
What is nvm, exactly?
nvm (Node Version Manager) is a command-line tool that lets you install and switch between multiple versions of Node.js on the same machine. If one project needs Node 24 and another needs Node 22, you do not uninstall and reinstall anything — you run nvm use 22 and keep working. This is how to use nvm in a sentence: install it once, install the Node versions you need, and switch between them per project or per terminal session.
nvm is designed to be installed per user and invoked per shell, and it works on any POSIX-compliant shell (bash, zsh, dash, ksh) on macOS, Linux, and Windows WSL, according to the official nvm README. Each Node version it installs lives in its own folder under ~/.nvm, completely isolated from the others. Think of this page as an nvm for beginners walkthrough and a compact nvm tutorial in one. If you manage a Node project at all, grabbing a package.json generator first makes the scaffolding painless, and nvm makes the runtime side just as painless.
What do you need before you install nvm?
You need a terminal, a supported shell, and about five minutes. nvm does not need root privileges, and you should not install it with sudo — it is a per-user tool that lives in your home directory. You also need to know which shell profile file your terminal reads, because the installer adds a few lines to it.
On macOS the default shell has been zsh since macOS 10.15, so the file is usually ~/.zshrc; on Linux with bash it is usually ~/.bashrc. If you are brand new to the terminal, our VS Code beginner guide gets your editor and integrated terminal set up first. One more thing Windows users should know up front: the classic nvm does not run on stock Windows, and that is covered in its own section below.
How do you install nvm on Mac or Linux?
You install nvm by running the official install script from the nvm GitHub repository. Follow these steps exactly, in order:
- Open your terminal and run the install script with curl:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash(v0.40.8 is the current release as of October 2026; check the nvm README for the newest tag before you run it). Prefer wget? Usewget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bashinstead. - Let the script finish. It clones the nvm repository into
~/.nvmand appends the loading lines to your shell profile file (~/.bashrc,~/.bash_profile,~/.zshrc, or~/.profile, whichever it detects). - Close your terminal completely and open a new one. This is the step beginners skip most often — the new terminal session is what actually loads nvm.
- Verify the install with
command -v nvm. If it printsnvm, you are done.
Use command -v nvm and not which nvm for the check. nvm is a sourced shell function, not a standalone binary, so which cannot see it — the official README calls this out explicitly because it trips up nearly every beginner. If command -v nvm prints nothing, your shell did not source the profile lines: either restart the terminal again or run the two export/source lines the installer printed and retry. On macOS with zsh, if ~/.zshrc did not exist, create it with touch ~/.zshrc and rerun the installer.
How do you install nvm on Windows?
You do not install the classic nvm on Windows — you use one of two different paths. The official nvm (nvm-sh/nvm) is POSIX-only, but the README says it works through WSL (Windows Subsystem for Linux), Git Bash, or Cygwin. So path one: install WSL, open its Ubuntu terminal, and follow the Mac/Linux install steps above verbatim.
Path two is nvm-windows, a completely separate project by Corey Butler that is neither supported nor developed by the nvm team. You download its installer from the nvm-windows GitHub releases page, run it, open a fresh terminal, and use a similar-but-not-identical command set. Never mix the two up in tutorials: if a guide's commands do not work on your Windows machine, check whether it was written for nvm-sh/nvm or for nvm-windows. If you searched for nvm windows specifically, the WSL path above is the one most developers actually choose. For this guide, everything from here on assumes the classic nvm on macOS, Linux, or WSL.
How do you install a Node version with nvm?
You install a Node version with nvm install followed by a version number, a major line, or a special alias. The three forms beginners use most are:
nvm install 24 # the latest Node 24.x release
nvm install 22 # the latest Node 22.x release
nvm install --lts # the latest Long-Term Support release
nvm install node # the absolute latest Node release (Current)
The official README's own example shows what success looks like: nvm install 24 answers Now using node v24.14.0 (npm v11.9.0). Installing a version also switches you to it immediately, so there is no separate activation step. To see everything you have installed, run nvm ls — and to see every version available for download, run nvm ls-remote (the list is long, so pipe it to less).
Beginners should almost always install an LTS line, not Current. As of October 2026 the live LTS lines are Node 26, Node 24 (codename Krypton), and Node 22 (codename Jod), per nodejs.org — the LTS-versus-Current choice gets its own section below. Installing takes a minute or two per version the first time because nvm downloads the official Node binaries.
How do you switch Node versions with nvm use?
You switch versions with nvm use followed by the version you want, and the switch applies to your current terminal session only. Run nvm use 22 and the official example output is Now using node v22.22.1 (npm v10.9.4); run node -v afterward and it reports v22.22.1. Open a second terminal tab and it still uses whatever the default is — the switch is scoped to the shell where you ran it.
That per-shell scoping is the feature, not a bug. You can run the legacy client on Node 22 in one terminal and the new API on Node 24 in another, side by side, with zero conflicts. Check what is active any time with nvm current, and confirm the binary path with nvm which 22. To leave nvm's versions entirely and fall back to a system-installed Node, run nvm use system.
How do you set a default Node version with nvm alias default?
You set the version every new terminal starts with by running nvm alias default followed by a version. nvm alias default 24 makes Node 24 the version that loads automatically in every fresh shell. Run nvm alias default with no argument to see which version is currently the default.
Set the default as soon as you have your first version installed, because otherwise every new terminal opens with no Node on the PATH at all and node -v fails. A sensible beginner setup: nvm install --lts, then nvm alias default pointing at that same LTS line. You can change the default any time — it is just an alias file, and nvm alias with no arguments lists every alias you have created.
What is .nvmrc and how do you use it?
An .nvmrc file is a tiny text file in your project's root that records which Node version the project needs, so every developer (and your CI) uses the same one. Create it with one command: echo "24" > .nvmrc. From then on, running bare nvm use inside that project directory reads the file and switches to Node 24 automatically.
The file can hold a full version (24.14.0), a major line (24), or an alias like lts/*. Commit it to the repo — it is the cheapest possible documentation of your runtime requirement, and teammates just run nvm use after cloning. If you keep your projects on GitHub, our GitHub beginner guide covers committing files like this the first time. One caution from the official docs: nvm use with no .nvmrc and no version argument errors out rather than guessing, which is exactly the behavior you want in a shared project.
How do you make nvm switch versions automatically?
You make nvm switch automatically by adding a small directory-change hook to your shell profile, a pattern the official README documents under "Deeper Shell Integration" for bash, zsh, and fish. The hook watches every cd: when you enter a directory containing an .nvmrc, it runs nvm use for you; when you leave, it can revert to your default version.
Copy the hook from the official nvm README's shell-integration section rather than from a random blog snippet — the README's version handles edge cases like reverting correctly, and blog copies drift. Paste it into ~/.zshrc or ~/.bashrc, restart the terminal, and test it: cd into a project with an .nvmrc and watch the version change on its own. If you would rather not touch your shell config, the manual habit works fine too: cd into the project, run nvm use, get to work.
Which Node version should beginners pick: LTS or Current?
Beginners should pick an LTS (Long-Term Support) release for anything real, because Node.js itself says production applications should only use Active LTS or Maintenance LTS releases. LTS versions get security fixes and critical bug fixes for 30 months; Current releases are six-month proving grounds where library authors shake out compatibility. When a tutorial tells you to install the newest Node, check whether it means newest LTS or newest Current — the difference matters.
Here is the landscape as of October 2026, from nodejs.org: Node 26 is the newest LTS, Node 24 (Krypton) is LTS, and Node 22 (Jod) is LTS. Node 27 entered Alpha on October 29, 2026 under the new annual release cycle, and everything from Node 20 downward is end-of-life. The pragmatic beginner move is nvm install --lts, which grabs the newest LTS line, then nvm alias default to make it your daily driver. That is the whole nvm lts workflow most developers settle on: install the LTS once, set it as the default, and add older lines only per project. Install an older LTS alongside it only when a specific project demands one — for example nvm install 22 for a legacy client that has not upgraded yet.
nvm vs Volta: which Node version manager should you pick?
Pick nvm if you want the battle-tested POSIX standard with explicit control; pick Volta if you want version switching to happen invisibly per project. Volta is, in its own words, "a hassle-free way to manage your JavaScript command-line tools": you run volta pin node@20 in a project and it records the exact version in a "volta" section of package.json, which you commit to git. From then on, anyone with Volta installed gets the right Node version automatically in that directory — no nvm use, no shell hooks.
| nvm | Volta | |
|---|---|---|
| How versions switch | You run nvm use, or a shell hook does it on cd | Automatic, via shims in your PATH — no shell hooks, per the official Volta docs |
| Where the pin lives | .nvmrc file at the project root | "volta" section inside package.json |
| Also manages | Node.js versions (and npm bundled with them) | Node, npm, yarn, pnpm versions, plus global tool installs pinned to a Node engine |
| Windows support | Via WSL; native Windows needs the separate nvm-windows project | Native macOS, Linux, and Windows support including WSL |
| Speed story | Shell-function based; loads with your shell profile | Written in Rust, single static binary, shim-based routing |
| Community size | The long-standing default; most tutorials assume it | Newer and smaller, but growing; one migration guide notes Volta even reads .nvmrc |
For a beginner following tutorials, nvm is the safer choice because nearly every guide you will read assumes it. Volta is the more ergonomic choice for teams that want the version pin to travel inside package.json and switch without anyone remembering a command. Both are legitimate; the wrong move is installing neither and fighting a single system-wide Node across projects.
What are the biggest nvm gotchas beginners hit?
The biggest gotcha is that global npm packages are installed per Node version, not shared. Install typescript globally on Node 24, switch to Node 22, and tsc is gone — each version has its own global package folder. This surprises everyone exactly once, and it is documented behavior, not a bug.
nvm gives you two clean ways to handle it. When installing a new Node version, carry your globals along: nvm install 24 --reinstall-packages-from=22 installs Node 24 and reinstalls the global packages from your Node 22 setup. Or move them later with nvm reinstall-packages 22. Either way, treat global installs as disposable conveniences — project dependencies belong in each project's package.json, installed with npm install, and never depend on a global package being present.
The second gotcha is reaching for nvm on production servers. nvm is built for development machines: it is per-user, per-shell, and interactive by nature. For servers and CI, pin the Node version in your deployment artifact instead — the official README itself documents Docker patterns for this. If Docker is new to you, start with our Docker beginner guide; a FROM node:24 line in a Dockerfile is the production equivalent of nvm use 24.
nvm command cheat sheet
Every nvm command a beginner needs, on one table. Bookmark this section.
| Command | What it does | Example |
|---|---|---|
nvm install <version> | Installs a Node version and switches to it | nvm install 24 |
nvm install --lts | Installs the newest LTS release | nvm install --lts |
nvm install node | Installs the newest Current release | nvm install node |
nvm use <version> | Switches the current shell to a version | nvm use 22 |
nvm use | Reads .nvmrc in the current directory and switches to it | nvm use |
nvm ls | Lists installed versions (arrow marks the active one) | nvm ls |
nvm ls-remote | Lists every downloadable version | nvm ls-remote --lts |
nvm current | Shows the active version | nvm current |
nvm alias default <version> | Sets the version new shells start with | nvm alias default 24 |
nvm alias | Lists all your aliases | nvm alias |
nvm uninstall <version> | Removes an installed version | nvm uninstall 20 |
nvm which <version> | Shows the binary path for a version | nvm which 24 |
nvm run <version> <file> | Runs a file with a specific version without switching | nvm run 22 app.js |
nvm exec <version> <cmd> | Runs any command with a specific version | nvm exec 22 npm test |
nvm reinstall-packages <version> | Copies global packages from one version to the current one | nvm reinstall-packages 22 |
command -v nvm | Verifies nvm loaded (it is a shell function) | command -v nvm |
Sources
- nvm-sh/nvm official README (github.com/nvm-sh/nvm) — install script v0.40.8,
command -v nvmverification, per-user/per-shell design, WSL and Windows notes, .nvmrc and deeper shell integration sections; fetched 2026-10-30 - nvm-sh/nvm releases page (github.com/nvm-sh/nvm/releases) — v0.40.8 current release, September 2026; fetched 2026-10-30
- nodejs.org/en/about/previous-releases — Node 26/24 (Krypton)/22 (Jod) LTS lines, Node 27 Alpha (Oct 29, 2026), production guidance (Active/Maintenance LTS only); fetched 2026-10-30
- SitePoint, "Quick Tip: Multiple Versions of Node with nvm" — command reference and auto-switch hook; fetched 2026-10-30
- dev.to/scriptbinary, "Managing Multiple Node.js Versions with nvm" — global-packages-are-per-version gotcha,
--reinstall-packages-fromusage; fetched 2026-10-30 - Volta official docs (docs.volta.sh/guide) —
volta install/volta pin, package.json volta section, shim-based automatic switching; fetched 2026-10-30 - dev.to/khriztianmoreno, "Introduction to Volta" — team workflow,
volta pincommitting to git; fetched 2026-10-30
Frequently asked questions
Do I need nvm if I only work on one project?
Not urgently, but install it anyway. The moment a second project, a tutorial, or a client repo needs a different Node version, nvm turns a reinstall ordeal into one command. It costs five minutes now and saves an afternoon later.
Why does nvm say "command not found" right after installing?
Your current terminal session started before nvm's loading lines were added to your shell profile. Close the terminal and open a new one, or source your profile file manually (source ~/.zshrc or source ~/.bashrc). Then verify with command -v nvm.
Can nvm manage npm and pnpm versions too?
Partly. Each Node version ships with its own bundled npm, so switching Node versions switches npm too. For other package managers, install them per project or look at Volta, which pins npm, yarn, and pnpm versions alongside Node in package.json.
Should I put .nvmrc in every project?
Yes for anything shared or long-lived. It is one line, it documents the runtime requirement, and nvm use with no arguments just works for anyone who clones the repo. Solo throwaway experiments can skip it.
Is nvm safe to use with Homebrew-installed Node?
They can coexist, but pick one as your primary to avoid confusion. If you install Node via both Homebrew and nvm, your PATH order decides which node wins in each shell. Most nvm users uninstall the Homebrew Node and let nvm own version management completely.