nvm-sh/nvm
Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions.
About nvm-sh/nvm
nvm-sh/nvm is an open-source project on GitHub, mainly written in Shell. Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions. It currently holds 95,913 stars and 10,753 forks with 372 open issues, and was last pushed on 2026-11-12 (repository created 2010-04-15).
Project Overview
Git Homed tracks it on the Today's Trending board, currently at rank #93 with 46 new stars today.
GitHub Repository Details
README
Node Version Manager [
][3] [
][4] 
Table of Contents
- Intro
- About
- Installing and Updating
- Install & Update Script
- Additional Notes
- Installing in Docker
- Installing in Docker for CICD-Jobs
- Troubleshooting on Linux
- Troubleshooting on macOS
- Ansible
- Verify Installation
- Important Notes
- Git Install
- Manual Install
- Manual Upgrade
- Usage
- Long-term Support
- Version Categories
- Migrating Global Packages While Installing
- Migrating Global Packages Between Installed Versions
- Offline Install
- Default Global Packages From File While Installing
- io.js
- System Version of Node
- Listing Versions
- Setting Custom Colors
- Persisting custom colors
- Suppressing colorized output
- Restoring PATH
- Set default node version
- Use a mirror of node binaries
- Pass Authorization header to mirror
- Platforms without official binaries
- .nvmrc
- Deeper Shell Integration
- Calling
nvm useautomatically in a directory with a.nvmrcfile - bash
- zsh
- fish
- Running Tests
- Environment variables
- Bash Completion
- Usage
- Compatibility Issues
- Installing nvm on Alpine Linux
- Alpine Linux 3.13+
- Alpine Linux 3.5 - 3.12
- Uninstalling / Removal
- Manual Uninstall
- Docker For Development Environment
- Problems
- macOS Troubleshooting
- WSL Troubleshooting
- Maintainers
- Project Support
- Enterprise Support
- License
- Copyright notice
Intro
nvm allows you to quickly install and use different versions of node via the command line.
Example:
$ nvm install 24
Now using node v24.14.0 (npm v11.9.0)
$ node -v
v24.14.0
$ nvm use 22
Now using node v22.22.1 (npm v10.9.4)
$ node -v
v22.22.1
$ nvm use 20
Now using node v20.20.1 (npm v10.8.2)
$ node -v
v20.20.1
Simple as that!
About
nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell.nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and Windows WSL.
Installing and Updating
Install & Update Script
To install or update nvm, you should run the [install script][2]. To do that, you may either download and run the script manually, or use the following cURL or Wget command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bashrc, ~/.bash_profile, ~/.zshrc, or ~/.profile). If you find the install script is updating the wrong profile file, set the $PROFILE env var to the profile file’s path, and then rerun the installation script.
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Additional Notes
- If the environment variable
$XDG_CONFIG_HOMEis present, it will place thenvmfiles there. - You can add
--no-useto the end of the above script to postpone usingnvmuntil you manuallyuseit:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm, without auto-using the default version
- You can customize the install source, directory, profile, and version using the
NVM_SOURCE,NVM_DIR,PROFILE, andNODE_VERSIONvariables.
curl ... | NVM_DIR="path/to/nvm". Ensure that the NVM_DIR does not contain a trailing slash.
- The installer can use
git,curl, orwgetto downloadnvm, whichever is available. - You can instruct the installer to not edit your shell config (for example if you already get completions via a zsh nvm plugin) by setting
PROFILE=/dev/nullbefore running theinstall.shscript. Here's an example one-line command to do that:PROFILE=/dev/null bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash'
Installing in Docker
When invoking bash as a non-interactive shell, like in a Docker container, none of the regular profile files are sourced. In order to use nvm, node, and npm like normal, you can instead specify the special BASH_ENV variable, which bash sources when invoked non-interactively.
# Use bash for the shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Create a script file sourced by both interactive and non-interactive bash shells
ENV BASH_ENV="${HOME:-/root}/.bash_env"
RUN touch "${BASH_ENV}"
RUN echo '. "${BASH_ENV}"' >> ~/.bashrc
Download and install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | PROFILE="${BASH_ENV}" bash
RUN echo node > .nvmrc
RUN nvm install
Installing in Docker for CICD-Jobs
More robust, works in CI/CD-Jobs. Can be run in interactive and non-interactive containers. See https://github.com/nvm-sh/nvm/issues/3531.
FROM ubuntu:latest
ARG NODE_VERSION=20
install curl
RUN apt update && apt install curl -y
install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
set env
ENV NVM_DIR="${HOME:-/root}/.nvm"
install node
RUN bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION"
set ENTRYPOINT for reloading nvm-environment
ENTRYPOINT ["bash", "-c", "source $NVM_DIR/nvm.sh && exec \"$@\"", "--"]
set cmd to bash
CMD ["/bin/bash"]
This example defaults to installation of nodejs version 20.x.y. Optionally you can easily override the version with docker build args like:
docker build -t nvmimage --build-arg NODE_VERSION=19 .
After creation of the image you can start container interactively and run commands, for example:
docker run --rm -it nvmimage
root@0a6b5a237c14:/# nvm -v
0.41.0
root@0a6b5a237c14:/# node -v
v19.9.0
root@0a6b5a237c14:/# npm -v
9.6.3
Noninteractive example:
user@host:/tmp/test $ docker run --rm -it nvmimage node -v
v19.9.0
user@host:/tmp/test $ docker run --rm -it nvmimage npm -v
9.6.3
Troubleshooting on Linux
On Linux, after running the install script, if you get nvm: command not found or see no feedback from your terminal after you type command -v nvm, simply close your current terminal, open a new terminal, and try verifying again.
Alternatively, you can run the following commands for the different shells on the command line:
bash: source ~/.bashrc
zsh: source ~/.zshrc
ksh: . ~/.profile
These should pick up the nvm command.
Troubleshooting on macOS
Since OS X 10.9, /usr/bin/git has been preset by Xcode command line tools, which means we can't properly detect if Git is installed or not. You need to manually install the Xcode command line tools before running the install script, otherwise, it'll fail. (see #1782)
If you get nvm: command not found after running the install script, one of the following might be the reason:
- Since macOS 10.15, the default shell is
zshand nvm will look for.zshrcto update, none is installed by default. Create one withtouch ~/.zshrcand run the install script again. - If you use bash, the previous default shell, your system may not have
.bash_profileor.bashrcfiles where the command is set up. Create one of them withtouch ~/.bash_profileortouch ~/.bashrcand run the install script again. Then, run. ~/.bash_profileor. ~/.bashrcto pick up thenvmcommand. - You have previously used
bash, but you havezshinstalled. You need to manually add these lines to~/.zshrcand run. ~/.zshrc. - You might need to restart your terminal instance or run
. ~/.nvm/nvm.sh. Restarting your terminal/opening a new tab/window, or running the source command will load the command and the new configuration. - If the above didn't help, you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
- If you use bash, it may be that your
.bash_profile(or~/.profile) does not source your~/.bashrcproperly. You could fix this by addingsource ~/<your_profile_file>to it or following the next step below. - Try adding the snippet from the install section, that finds the correct nvm directory and loads nvm, to your usual profile (
~/.bash_profile,~/.zshrc,~/.profile, or~/.bashrc). - For more information about this issue and possible workarounds, please refer here
nvm, you may want to update to one of those versions or later.
Ansible
You can use a task:
- name: Install nvm
ansible.builtin.shell: >
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
args:
creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
Verify Installation
To verify that nvm has been installed, do:
command -v nvm
which should output nvm if the installation was successful. Please note that which nvm will not work, since nvm is a sourced shell function, not an executable binary.
Note: On Linux, after running the install script, if you get nvm: command not found or see no feedback from your terminal after you type command -v nvm, simply close your current terminal, open a new terminal, and try verifying again.
Important Notes
If you're running a system without prepackaged binary available, which means you're going to install node or io.js from its source code, you need to make sure your system has a C++ compiler. For OS X, Xcode will work, for Debian/Ubuntu based GNU/Linux, the build-essential and libssl-dev packages work.
Note: nvm also supports Windows in some cases. It should work through WSL (Windows Subsystem for Linux) depending on the version of WSL. It should also work with Git Bash (MSYS) or Cygwin. Otherwise, for Windows, a few alternatives exist, which are neither supported nor developed by us:
nvm does not support [Fish] either (see #303). Alternatives exist, which are neither supported nor developed by us:
- bass allows you to use utilities written for Bash in fish shell
- fast-nvm-fish only works with version numbers (not aliases) but doesn't significantly slow your shell startup
- plugin-nvm plugin for Oh My Fish, which makes nvm and its completions available in fish shell
- nvm.fish - The Node.js version manager you'll adore, crafted just for Fish
- fish-nvm - Wrapper around nvm for fish, delays sourcing nvm until it's actually used.
- [[#900] [Bug] node on FreeBSD may need to be patched](https://github.com/nvm-sh/nvm/issues/900)
- nodejs/node#3716
Command Line Tools. You can check out this blog post on how to just that:
Note: On OS X, if you have/had a "system" node installed and want to install modules globally, keep in mind that:
- When using
nvmyou do not needsudoto globally install a module withnpm -g, so instead of doingsudo npm install -g grunt, do insteadnpm install -g grunt - If you have an
~/.npmrcfile, make sure it does not contain anyprefixsettings (which is not compatible withnvm) - You can (but should not?) keep your previous "system" node install, but
nvmwill only be available to your user account (the one used to install nvm). This might cause version mismatches, as other users will be using/usr/local/lib/node_modules/VS your user account using~/.nvm/versions/node/vX.X.X/lib/node_modules/
nvm, please brew uninstall it, and install it using the instructions below, before filing an issue.
Note: If you're using zsh you can easily install nvm as a zsh plugin. Install zsh-nvm and run nvm upgrade to upgrade (you can set NVM_AUTO_USE=true to have it automatically detect and use .nvmrc files).
Note: Git versions before v1.7 may face a problem of cloning nvm source from GitHub via https protocol, and there is also different behavior of git before v1.6, and git prior to v1.17.10 can not clone tags, so the minimum required git version is v1.7.10. If you are interested in the problem we mentioned here, please refer to GitHub's HTTPS cloning errors article.
Git Install
If you have git installed (requires git v1.7.10+):
1. clone this repo in the root of your user profile
cd ~/from anywhere thengit clone https://github.com/nvm-sh/nvm.git .nvm
cd ~/.nvm and check out the latest version with git checkout v0.41.0
1. activate nvm by sourcing it from your shell: . ./nvm.sh
Now add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login:
(you may have to add to more than one of the above files)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Manual Install
For a fully manual install, execute the following lines to first clone the nvm repository into $HOME/.nvm, and then load nvm:
export NVM_DIR="$HOME/.nvm" && (
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)
) && \. "$NVM_DIR/nvm.sh"
Now add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login:
(you may have to add to more than one of the above files)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Manual Upgrade
For manual upgrade with git (requires git v1.7.10+):
1. change to the $NVM_DIR
1. pull down the latest changes
1. check out the latest version
1. activate the new version
(
cd "$NVM_DIR"
git fetch --tags origin
git checkout git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)
) && \. "$NVM_DIR/nvm.sh"
Usage
To download, compile, and install the latest release of node, do this:
nvm install node # "node" is an alias for the latest version
To install a specific version of node:
nvm install 14.7.0 # or 16.3.0, 12.22.1, etc
To set an alias:
nvm alias my_alias v14.4.0
Make sure that your alias does not contain any spaces or slashes.
The first version installed becomes the default. New shells will start with the default version of node (e.g., nvm alias default).
You can list available versions using ls-remote:
nvm ls-remote
When no version or --lts filter is given, the list also marks the version the node alias would install, and every version that one of your own aliases would resolve to. Each kind of annotation always starts in the same column, so the output can be sliced with cut -c or similar tools:
v20.9.0 (Latest LTS: Iron) (Aliases: work)
v21.0.0
v21.1.0
v21.2.0 (Latest: node) (Aliases: default)
And then in any new shell just use the installed version:
nvm use node
Or you can just run it:
nvm run node --version
Or, you can run any arbitrary command in a subshell with the desired version of node:
nvm exec 4.2 node --version
You can also get the path to the executable to where it was installed:
nvm which 12.22
In place of a version pointer like "14.7" or "16.3" or "12.22.1", you can use the following special default aliases with nvm install, nvm use, nvm run, nvm exec, nvm which, etc:
node: this installs the latest version ofnodeiojs: this installs the latest version ofio.jsstable: this alias is deprecated, and only truly applies tonodev0.12and earlier. Currently, this is an alias fornode.unstable: this alias points tonodev0.11- the last "unstable" node release, since post-1.0, all node versions are stable. (in SemVer, versions communicate breakage, not stability).current: the version currently active in this shell (i.e. whatnoderesolves to via$PATH). It is not affected by.nvmrc. Useful when you want to refer to the active version explicitly — e.g.nvm which currentalways prints the path to the activenode, regardless of whether an.nvmrcfile is present.
Long-term Support
Node has a schedule for long-term support (LTS) You can reference LTS versions in aliases and .nvmrc files with the notation lts/* for the latest LTS, and lts/argon for LTS releases from the "argon" line, for example. In addition, the following commands support LTS arguments:
nvm install --lts/nvm install --lts=argon/nvm install 'lts/*'/nvm install lts/argonnvm uninstall --lts/nvm uninstall --lts=argon/nvm uninstall 'lts/*'/nvm uninstall lts/argonnvm use --lts/nvm use --lts=argon/nvm use 'lts/*'/nvm use lts/argonnvm exec --lts/nvm exec --lts=argon/nvm exec 'lts/*'/nvm exec lts/argonnvm run --lts/nvm run --lts=argon/nvm run 'lts/*'/nvm run lts/argonnvm ls-remote --lts/nvm ls-remote --lts=argonnvm ls-remote 'lts/*'/nvm ls-remote lts/argonnvm version-remote --lts/nvm version-remote --lts=argon/nvm version-remote 'lts/*'/nvm version-remote lts/argon
nvm connects to https://nodejs.org, it will re-create the appropriate local aliases for all available LTS lines. These aliases (stored under $NVM_DIR/alias/lts), are managed by nvm, and you should not modify, remove, or create these files - expect your changes to be undone, and expect meddling with these files to cause bugs that will likely not be supported.
To get the latest LTS version of node and migrate your existing installed packages, use:
nvm install --reinstall-packages-from=current 'lts/*'
Version Categories
Every version of node belongs to exactly one of these categories:
alpha: an Alpha prerelease, likev27.0.0-alpha.1.0.0, which precedes a major's first releaselts: a version marked as LTS in the mirror'sindex.tabnon-lts: any other version of nodeiojs: any version of io.js, from the io.js mirror
nvm selects versions from every category except alpha, so nvm install node, nvm install 27, and nvm ls-remote never pick or show an Alpha. Every command that selects or lists versions accepts --only= with a comma