
Nvm
Switch Node.js versions per shell with a single bash command
Replaces —

Who it's for
Switching between a Next.js app pinned to Node 20 and a legacy API on Node 16 takes one command with nvm. A `.nvmrc` in each project root lets shell hooks handle the switch automatically on `cd`, so the right version is always active without manual intervention.
You have a single Node.js project that never changes versions and no legacy codebases. A single system Node.js installation from your package manager is simpler when there is nothing to switch between.
nvm installs without root access, making it suitable for deploying Node.js services in user space on Linux servers. It lets you install a newer Node version alongside the running one and test it before cutting over, with no system package manager involvement.
You run Node.js in Docker containers. A pinned base image (`node:20-alpine`) is more reproducible and requires no runtime version manager inside the container.
nvm's `--lts` flag and named aliases make it straightforward to install the right Node.js version at the start of a CI job. The `BASH_ENV` pattern in the README handles non-interactive shell sourcing in Docker-based CI runners.
Your CI platform (GitHub Actions, CircleCI) already provides a `node-version` input or built-in matrix strategy. Use the platform-native version pinning when available; it is simpler and avoids sourcing nvm inside scripts.
Because nvm requires no root access and writes only to `~/.nvm`, it works on shared hosting accounts and corporate developer machines where system Node.js was installed by IT. You can install and use any Node.js version without filing a support ticket.
Your environment uses Fish shell or another non-POSIX shell natively. Fish users need a community wrapper; see the README for the available options.
The problem
Every Node.js developer eventually hits the same wall: one project pins to Node 18 for LTS stability, another needs Node 20 for a specific module, and a third was built on Node 16 and breaks on anything newer. Installing Node.js at the system level means one active version for all of them. Upgrading for one project breaks another, and rolling back requires a full uninstall and reinstall cycle. The workaround most developers land on before discovering a version manager is to keep a single LTS version and accept that some projects will behave unpredictably, or to spend time debugging failures that are actually just version mismatches. CI/CD pipelines that pin to a specific Node version expose these gaps when a local development version drifts. Manual PATH manipulation to point at different Node binaries is fragile and easy to forget to undo.
How it works
Set the active Node.js version for the current shell session with `nvm use <version>`. The change is scoped to that shell and does not affect other terminals or other users on the same machine. Running `nvm use 20` in one tab and `nvm use 18` in another works simultaneously.
Add a `.nvmrc` file to any project directory containing the target Node.js version number or alias (e.g., `20` or `lts/iron`). Shell hooks for bash and zsh can auto-run `nvm use` when you enter the directory, eliminating manual switching entirely.
Install the latest Long-Term Support Node.js release with `nvm install --lts` without looking up the version number. Named aliases like `lts/hydrogen` and `lts/iron` let you pin to a specific LTS line and upgrade within it using `nvm install lts/iron --reinstall-packages-from=current`.
When installing a new Node.js version, pass `--reinstall-packages-from=<version>` to carry global npm packages forward. This preserves globally installed tools like eslint or tsx without manually reinstalling each one after a version switch.
Use nvm inside Docker containers and CI jobs by setting the `BASH_ENV` variable so nvm loads in non-interactive shells. The README includes Dockerfile examples for both interactive and CI-style container setups, including an Ubuntu-based CI pattern that works across interactive and non-interactive containers.
Features
- Per-shell Node.js version switching
- Per-project version pinning via .nvmrc
- LTS alias tracking
- Global package migration between versions
- Docker and CI/CD compatibility
How to install
Install nvm via the official curl script, which clones the repository to ~/.nvm and updates your shell profile.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bashRecommended for this setup
Strengths
- Per-user install, no root access required: nvm installs entirely under `~/.nvm` in user space with no sudo, no system-directory writes, and no risk of breaking other users' Node installations on a shared server. This makes it safe on shared hosting environments and developer machines where system Node was installed separately.
- 95,469 GitHub stars and maintained since 2010: nvm has been actively maintained since April 2010 and reached 95,469 GitHub stars, making it the most widely adopted Node.js version manager. The project follows CII Best Practices, has an active test suite, and received its last push in October 2026. Community documentation covers edge cases on macOS, Alpine Linux, FreeBSD, and Windows WSL.
- MIT license with no commercial restrictions: The MIT license imposes no restrictions on commercial use, forking, or modification. Teams can include nvm in proprietary build pipelines, corporate CI environments, and commercial hosting setups without attribution requirements beyond the license notice.
- Works with any POSIX-compliant shell: nvm runs on bash, dash, ksh, zsh, and sh. It requires no architecture-specific binary download; the same install script works on x86 Linux, Apple Silicon Macs (with native arm64 Node support since v16), and ARM servers. Alpine Linux has documented workarounds in the README.
Trade-offs
- Shell startup time overhead: Because nvm is a sourced shell function rather than a binary, sourcing it on every new shell invocation adds a small but measurable delay to terminal startup. On slower machines or shells that source many plugins, this becomes noticeable. Alternatives like fnm or Volta use compiled binaries with sub-millisecond startup overhead.
- No native Fish shell support: nvm does not support the Fish shell. Fish users must choose from community-maintained wrappers (bass, plugin-nvm, nvm.fish, fish-nvm) that replicate the functionality, none of which are officially supported or developed by the nvm project.
- Per-user only, not per-system: nvm is installed per-user, so different system users have separate nvm installations and separate Node.js versions. If a deployment workflow runs Node.js services as a different system user than the one who installed nvm, you need to install nvm again for that user or use a different version management approach.
Tech stack
FAQ
Yes. nvm is MIT licensed, which means it can be used freely in commercial and proprietary projects with no restrictions beyond retaining the copyright notice. There is no paid tier, no usage limit, and no vendor agreement required.
Run `nvm install <version>` where version is a version number (e.g., `nvm install 20`), a named alias (`nvm install lts/iron`), or `--lts` for the latest Long-Term Support release. After installing, activate it in the current shell with `nvm use <version>`. Set a persistent default for new shells with `nvm alias default <version>`.
nvm-sh/nvm works on Windows through WSL (Windows Subsystem for Linux) and Git Bash/MSYS/Cygwin. Native Windows users without WSL should use nvm-windows (a separate, unrelated project) instead. The two projects share a name concept but have different codebases, and the nvm-sh team does not maintain nvm-windows.
A `.nvmrc` file placed in a project directory contains a Node.js version number or alias such as `20` or `lts/iron`. Running `nvm use` in that directory reads the file and switches to the specified version. Shell hooks for bash and zsh can call `nvm use` automatically whenever you change directories, so the switch happens without any manual command.
nvm is a POSIX shell function that activates a Node.js version per shell session. Volta and fnm are compiled binaries with lower shell startup overhead. Volta pins Node versions per-project in `package.json` rather than a separate `.nvmrc` file and supports Fish shell natively. fnm supports `.nvmrc` files like nvm but is written in Rust. nvm has the broadest adoption (95,469 GitHub stars), the most documented platform edge cases, and the longest community history since 2010.