Skip to content
Myr

README.md

This file

Path

README.md

1,259 lines · 56.9 KiB · Markdown

Last changed by

[readme] Fix a Docker warning from using Docker installation instructionsclifennelbefore adoption6dc3765

History of this file

Take it

Show it rendered

1<a href="https://github.com/nvm-sh/logos">2  <picture>3    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nvm-sh/logos/HEAD/nvm-logo-white.svg" />4    <img src="https://raw.githubusercontent.com/nvm-sh/logos/HEAD/nvm-logo-color.svg" height="50" alt="nvm project logo" />5  </picture>6</a>789# Node Version Manager [![Tests](https://github.com/nvm-sh/nvm/actions/workflows/tests-fast.yml/badge.svg?branch=master)][3] [![nvm version](https://img.shields.io/badge/version-v0.40.8-yellow.svg)][4] [![CII Best Practices](https://bestpractices.dev/projects/684/badge)](https://bestpractices.dev/projects/684)1011<!-- To update this table of contents, ensure you have run `npm install` then `npm run doctoc` -->12<!-- START doctoc generated TOC please keep comment here to allow auto update -->13<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->14## Table of Contents1516- [Intro](#intro)17- [About](#about)18- [Installing and Updating](#installing-and-updating)19  - [Install & Update Script](#install--update-script)20    - [Additional Notes](#additional-notes)21    - [Installing in Docker](#installing-in-docker)22      - [Installing in Docker for CICD-Jobs](#installing-in-docker-for-cicd-jobs)23    - [Troubleshooting on Linux](#troubleshooting-on-linux)24    - [Troubleshooting on macOS](#troubleshooting-on-macos)25    - [Ansible](#ansible)26  - [Verify Installation](#verify-installation)27  - [Important Notes](#important-notes)28  - [Git Install](#git-install)29  - [Manual Install](#manual-install)30  - [Manual Upgrade](#manual-upgrade)31- [Usage](#usage)32  - [Long-term Support](#long-term-support)33  - [Migrating Global Packages While Installing](#migrating-global-packages-while-installing)34  - [Migrating Global Packages Between Installed Versions](#migrating-global-packages-between-installed-versions)35  - [Offline Install](#offline-install)36  - [Default Global Packages From File While Installing](#default-global-packages-from-file-while-installing)37  - [io.js](#iojs)38  - [System Version of Node](#system-version-of-node)39  - [Listing Versions](#listing-versions)40  - [Setting Custom Colors](#setting-custom-colors)41    - [Persisting custom colors](#persisting-custom-colors)42    - [Suppressing colorized output](#suppressing-colorized-output)43  - [Restoring PATH](#restoring-path)44  - [Set default node version](#set-default-node-version)45  - [Use a mirror of node binaries](#use-a-mirror-of-node-binaries)46    - [Pass Authorization header to mirror](#pass-authorization-header-to-mirror)47  - [Platforms without official binaries](#platforms-without-official-binaries)48  - [.nvmrc](#nvmrc)49  - [Deeper Shell Integration](#deeper-shell-integration)50    - [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file)51      - [bash](#bash)52      - [zsh](#zsh)53      - [fish](#fish)54- [Running Tests](#running-tests)55- [Environment variables](#environment-variables)56- [Bash Completion](#bash-completion)57  - [Usage](#usage-1)58- [Compatibility Issues](#compatibility-issues)59- [Installing nvm on Alpine Linux](#installing-nvm-on-alpine-linux)60  - [Alpine Linux 3.13+](#alpine-linux-313)61  - [Alpine Linux 3.5 - 3.12](#alpine-linux-35---312)62- [Uninstalling / Removal](#uninstalling--removal)63  - [Manual Uninstall](#manual-uninstall)64- [Docker For Development Environment](#docker-for-development-environment)65- [Problems](#problems)66- [macOS Troubleshooting](#macos-troubleshooting)67- [WSL Troubleshooting](#wsl-troubleshooting)68- [Maintainers](#maintainers)69- [Project Support](#project-support)70- [Enterprise Support](#enterprise-support)71- [License](#license)72- [Copyright notice](#copyright-notice)7374<!-- END doctoc generated TOC please keep comment here to allow auto update -->7576## Intro7778`nvm` allows you to quickly install and use different versions of [node](https://nodejs.org) via the command line.7980**Example:**81```sh82$ nvm install 2483Now using node v24.14.0 (npm v11.9.0)84$ node -v85v24.14.086$ nvm use 2287Now using node v22.22.1 (npm v10.9.4)88$ node -v89v22.22.190$ nvm use 2091Now using node v20.20.1 (npm v10.8.2)92$ node -v93v20.20.194```9596Simple as that!979899## About100nvm is a version manager for [node.js](https://nodejs.org/en/), designed to be installed per-user, and invoked per-shell. `nvm` works on any POSIX-compliant shell (sh, [dash](https://git.kernel.org/pub/scm/utils/dash/dash.git), [ksh](https://github.com/ksh93/ksh), [zsh](https://www.zsh.org), [bash](https://www.gnu.org/software/bash/)), in particular on these platforms: unix, [macOS](https://www.apple.com/macos/), and [Windows WSL](https://github.com/nvm-sh/nvm#important-notes).101102<a id="installation-and-update"></a>103<a id="install-script"></a>104## Installing and Updating105106### Install & Update Script107108To **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](https://curl.se) or [Wget](https://www.gnu.org/software/wget/) command:109```sh110curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash111```112```sh113wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash114```115116Running 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.117118<a id="profile_snippet"></a>119```sh120export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"121[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm122```123124#### Additional Notes125126- If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.127128- You can add `--no-use` to the end of the above script to postpone using `nvm` until you manually [`use`](#usage) it:129130```sh131export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"132[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm, without auto-using the default version133```134135- You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables.136Eg: `curl ... | NVM_DIR="path/to/nvm"`. Ensure that the `NVM_DIR` does not contain a trailing slash.137138- The installer can use [`git`](https://git-scm.com/), `curl`, or `wget` to download `nvm`, whichever is available.139140- You can instruct the installer to not edit your shell config (for example if you already get completions via a [zsh nvm plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/nvm)) by setting `PROFILE=/dev/null` before running the `install.sh` script. 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.40.8/install.sh | bash'`141142#### Installing in Docker143144When invoking bash as a non-interactive shell, like in a [Docker](https://www.docker.com) container, none of the regular profile files are sourced. In order to use `nvm`, `node`, and [`npm`](https://www.npmjs.com) like normal, you can instead specify the special `BASH_ENV` variable, which bash sources when invoked non-interactively.145146```Dockerfile147# Use bash for the shell148SHELL ["/bin/bash", "-o", "pipefail", "-c"]149150# Create a script file sourced by both interactive and non-interactive bash shells151ENV BASH_ENV="${HOME:-/root}/.bash_env"152RUN touch "${BASH_ENV}"153RUN echo '. "${BASH_ENV}"' >> ~/.bashrc154155# Download and install nvm156RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | PROFILE="${BASH_ENV}" bash157RUN echo node > .nvmrc158RUN nvm install159```160161##### Installing in Docker for CICD-Jobs162163More robust, works in CI/CD-Jobs. Can be run in interactive and non-interactive containers.164See https://github.com/nvm-sh/nvm/issues/3531.165166```Dockerfile167FROM ubuntu:latest168ARG NODE_VERSION=20169170# install curl171RUN apt update && apt install curl -y172173# install nvm174RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash175176# set env177ENV NVM_DIR="${HOME:-/root}/.nvm"178179# install node180RUN bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION"181182# set ENTRYPOINT for reloading nvm-environment183ENTRYPOINT ["bash", "-c", "source $NVM_DIR/nvm.sh && exec \"$@\"", "--"]184185# set cmd to bash186CMD ["/bin/bash"]187188```189190This example defaults to installation of nodejs version 20.x.y. Optionally you can easily override the version with docker build args like:191```192docker build -t nvmimage --build-arg NODE_VERSION=19 .193```194195After creation of the image you can start container interactively and run commands, for example:196```197docker run --rm -it nvmimage198199root@0a6b5a237c14:/# nvm -v2000.40.8201202root@0a6b5a237c14:/# node -v203v19.9.0204205root@0a6b5a237c14:/# npm -v2069.6.3207```208209Noninteractive example:210```211user@host:/tmp/test $ docker run --rm -it nvmimage node -v212v19.9.0213user@host:/tmp/test $ docker run --rm -it nvmimage npm -v2149.6.3215```216217#### Troubleshooting on Linux218219On [Linux](https://www.kernel.org/), 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.220Alternatively, you can run the following commands for the different shells on the command line:221222*bash*: `source ~/.bashrc`223224*zsh*: `source ~/.zshrc`225226*ksh*: `. ~/.profile`227228These should pick up the `nvm` command.229230#### Troubleshooting on macOS231232Since OS X 10.9, `/usr/bin/git` has been preset by [Xcode](https://developer.apple.com/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](https://github.com/nvm-sh/nvm/issues/1782))233234If you get `nvm: command not found` after running the install script, one of the following might be the reason:235236  - Since macOS 10.15, the default shell is `zsh` and nvm will look for `.zshrc` to update, none is installed by default. Create one with `touch ~/.zshrc` and run the install script again.237238  - If you use bash, the previous default shell, your system may not have `.bash_profile` or `.bashrc` files where the command is set up. Create one of them with `touch ~/.bash_profile` or `touch ~/.bashrc` and run the install script again. Then, run `. ~/.bash_profile` or `. ~/.bashrc` to pick up the `nvm` command.239240  - You have previously used `bash`, but you have `zsh` installed. You need to manually add [these lines](#manual-install) to `~/.zshrc` and run `. ~/.zshrc`.241242  - 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.243244  - 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.245246If the above doesn't fix the problem, you may try the following:247248  - If you use bash, it may be that your `.bash_profile` (or `~/.profile`) does not source your `~/.bashrc` properly. You could fix this by adding `source ~/<your_profile_file>` to it or following the next step below.249250  - Try adding [the snippet from the install section](#profile_snippet), that finds the correct nvm directory and loads nvm, to your usual profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).251252  - For more information about this issue and possible workarounds, please [refer here](https://github.com/nvm-sh/nvm/issues/576)253254**Note** For Macs with the Apple Silicon chip, node started offering **arm64** arch Darwin packages since v16.0.0 and experimental **arm64** support when compiling from source since v14.17.0. If you are facing issues installing node using `nvm`, you may want to update to one of those versions or later.255256#### Ansible257258You can use a task:259260```yaml261- name: Install nvm262  ansible.builtin.shell: >263    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash264  args:265    creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"266```267268### Verify Installation269270To verify that nvm has been installed, do:271272```sh273command -v nvm274```275276which 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.277278**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.279280### Important Notes281282If you're running a system without prepackaged binary available, which means you're going to install node or [io.js](https://iojs.org) from its source code, you need to make sure your system has a C++ compiler. For OS X, Xcode will work, for [Debian](https://www.debian.org)/[Ubuntu](https://ubuntu.com) based GNU/Linux, the `build-essential` and `libssl-dev` packages work.283284**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](https://gitforwindows.org/) ([MSYS](https://www.msys2.org/)) or [Cygwin](https://cygwin.com). Otherwise, for Windows, a few alternatives exist, which are neither supported nor developed by us:285286  - [nvm-windows](https://github.com/coreybutler/nvm-windows)287  - [nodist](https://github.com/marcelklehr/nodist)288  - [nvs](https://github.com/jasongin/nvs)289290**Note:** `nvm` does not support [Fish] either (see [#303](https://github.com/nvm-sh/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:291292  - [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell293  - [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup294  - [plugin-nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell295  - [nvm.fish](https://github.com/jorgebucaran/nvm.fish) - The Node.js version manager you'll adore, crafted just for Fish296  - [fish-nvm](https://github.com/FabioAntunes/fish-nvm) - Wrapper around nvm for fish, delays sourcing nvm until it's actually used.297298**Note:** We still have some problems with [FreeBSD](https://www.freebsd.org), because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:299300  - [[#900] [Bug] node on FreeBSD may need to be patched](https://github.com/nvm-sh/nvm/issues/900)301  - [nodejs/node#3716](https://github.com/nodejs/node/issues/3716)302303**Note:** On OS X, if you do not have Xcode installed and you do not wish to download the ~4.3GB file, you can install the `Command Line Tools`. You can check out this blog post on how to just that:304305  - [How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode)](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)306307**Note:** On OS X, if you have/had a "system" node installed and want to install modules globally, keep in mind that:308309  - When using `nvm` you do not need `sudo` to globally install a module with `npm -g`, so instead of doing `sudo npm install -g grunt`, do instead `npm install -g grunt`310  - If you have an `~/.npmrc` file, make sure it does not contain any `prefix` settings (which is not compatible with `nvm`)311  - You can (but should not?) keep your previous "system" node install, but `nvm` will 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/*`312313[Homebrew](https://brew.sh) installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.314315**Note:** If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade ([you can set](https://github.com/lukechilds/zsh-nvm#auto-use) `NVM_AUTO_USE=true` to have it automatically detect and use `.nvmrc` files).316317**Note:** Git versions before v1.7 may face a problem of cloning `nvm` source from [GitHub](https://github.com) via https protocol, and there is also different behavior of git before v1.6, and git prior to [v1.17.10](https://github.com/git/git/commit/5a7d5b683f869d3e3884a89775241afa515da9e7) 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](https://help.github.com/articles/https-cloning-errors/) article.318319### Git Install320321If you have `git` installed (requires git v1.7.10+):3223231. clone this repo in the root of your user profile324    - `cd ~/` from anywhere then `git clone https://github.com/nvm-sh/nvm.git .nvm`3251. `cd ~/.nvm` and check out the latest version with `git checkout v0.40.8`3261. activate `nvm` by sourcing it from your shell: `. ./nvm.sh`327328Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:329(you may have to add to more than one of the above files)330331```sh332export NVM_DIR="$HOME/.nvm"333[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm334[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion335```336337### Manual Install338339For a fully manual install, execute the following lines to first clone the `nvm` repository into `$HOME/.nvm`, and then load `nvm`:340341```sh342export NVM_DIR="$HOME/.nvm" && (343  git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"344  cd "$NVM_DIR"345  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`346) && \. "$NVM_DIR/nvm.sh"347```348349Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:350(you may have to add to more than one of the above files)351352```sh353export NVM_DIR="$HOME/.nvm"354[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm355[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion356```357358### Manual Upgrade359360For manual upgrade with `git` (requires git v1.7.10+):3613621. change to the `$NVM_DIR`3631. pull down the latest changes3641. check out the latest version3651. activate the new version366367```sh368(369  cd "$NVM_DIR"370  git fetch --tags origin371  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`372) && \. "$NVM_DIR/nvm.sh"373```374375## Usage376377To download, compile, and install the latest release of node, do this:378379```sh380nvm install node # "node" is an alias for the latest version381```382383To install a specific version of node:384385```sh386nvm install 14.7.0 # or 16.3.0, 12.22.1, etc387```388389To set an alias:390391```sh392nvm alias my_alias v14.4.0393```394Make sure that your alias does not contain any spaces or slashes.395396The first version installed becomes the default. New shells will start with the default version of node (e.g., `nvm alias default`).397398You can list available versions using `ls-remote`:399400```sh401nvm ls-remote402```403404When 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:405406```407        v20.9.0   (Latest LTS: Iron)                        (Aliases: work)408        v21.0.0409        v21.1.0410        v21.2.0                            (Latest: node)   (Aliases: default)411```412413And then in any new shell just use the installed version:414415```sh416nvm use node417```418419Or you can just run it:420421```sh422nvm run node --version423```424425Or, you can run any arbitrary command in a subshell with the desired version of node:426427```sh428nvm exec 4.2 node --version429```430431You can also get the path to the executable to where it was installed:432433```sh434nvm which 12.22435```436437In 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:438439  - `node`: this installs the latest version of [`node`](https://nodejs.org/en/)440  - `iojs`: this installs the latest version of [`io.js`](https://iojs.org/en/)441  - `stable`: this alias is deprecated, and only truly applies to `node` `v0.12` and earlier. Currently, this is an alias for `node`.442  - `unstable`: this alias points to `node` `v0.11` - the last "unstable" node release, since post-1.0, all node versions are stable. (in [SemVer](https://semver.org), versions communicate breakage, not stability).443  - `current`: the version currently active in this shell (i.e. what `node` resolves to via `$PATH`). It is **not** affected by `.nvmrc`. Useful when you want to refer to the active version explicitly &mdash; e.g. `nvm which current` always prints the path to the active `node`, regardless of whether an `.nvmrc` file is present.444445### Long-term Support446447Node has a [schedule](https://github.com/nodejs/Release#release-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:448449  - `nvm install --lts` / `nvm install --lts=argon` / `nvm install 'lts/*'` / `nvm install lts/argon`450  - `nvm uninstall --lts` / `nvm uninstall --lts=argon` / `nvm uninstall 'lts/*'` / `nvm uninstall lts/argon`451  - `nvm use --lts` / `nvm use --lts=argon` / `nvm use 'lts/*'` / `nvm use lts/argon`452  - `nvm exec --lts` / `nvm exec --lts=argon` / `nvm exec 'lts/*'` / `nvm exec lts/argon`453  - `nvm run --lts` / `nvm run --lts=argon` / `nvm run 'lts/*'` / `nvm run lts/argon`454  - `nvm ls-remote --lts` / `nvm ls-remote --lts=argon` `nvm ls-remote 'lts/*'` / `nvm ls-remote lts/argon`455  - `nvm version-remote --lts` / `nvm version-remote --lts=argon` / `nvm version-remote 'lts/*'` / `nvm version-remote lts/argon`456457Any time your local copy of `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.458459To get the latest LTS version of node and migrate your existing installed packages, use:460461```sh462nvm install --reinstall-packages-from=current 'lts/*'463```464465### Migrating Global Packages While Installing466467If you want to install a new version of Node.js and migrate npm packages from a previous version:468469```sh470nvm install --reinstall-packages-from=node node471```472473This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one.474475You can also install and migrate npm packages from specific versions of Node like this:476477```sh478nvm install --reinstall-packages-from=5 6479nvm install --reinstall-packages-from=iojs v4.2480```481482Note that reinstalling packages _explicitly does not update the npm version_ — this is to ensure that npm isn't accidentally upgraded to a broken version for the new node version.483484To update npm at the same time add the `--latest-npm` flag, like this:485486```sh487nvm install --reinstall-packages-from=default --latest-npm 'lts/*'488```489490or, you can at any time run the following command to get the latest supported npm version on the current node version:491```sh492nvm install-latest-npm493```494495If you've already gotten an error to the effect of "npm does not support Node.js", you'll need to (1) revert to a previous node version (`nvm ls` & `nvm use <your latest _working_ version from the ls>`), (2) delete the newly created node version (`nvm uninstall <your _broken_ version of node from the ls>`), then (3) rerun your `nvm install` with the `--latest-npm` flag.496497### Migrating Global Packages Between Installed Versions498499`--reinstall-packages-from` is tied to `nvm install`. To migrate global npm packages between versions you _already_ have installed, without (re)installing anything, `nvm use` the destination and run `nvm reinstall-packages` as a standalone command, pointing at the version you want to copy _from_:500501```sh502nvm use 22.22.2503nvm reinstall-packages 22.20.0504```505506This reinstalls all global packages from `22.20.0` into the currently-active version (`22.22.2`). As with `--reinstall-packages-from`, the npm version itself is not changed.507508509### Offline Install510511If you've previously downloaded a node version (or it's still in the cache), you can install it without any network access using the `--offline` flag:512513```sh514nvm install --offline 14.7.0515```516517This resolves versions using only locally installed versions and cached downloads. It will not attempt to download anything. This is useful in air-gapped environments, on planes, or when you want to avoid network latency.518519You can combine `--offline` with `--lts` to install the latest cached LTS version (as long as LTS aliases have been populated by a prior `nvm ls-remote --lts`):520521```sh522nvm install --offline --lts523```524525### Default Global Packages From File While Installing526527If you have a list of default packages you want installed every time you install a new version, we support that too -- just add the package names, one per line, to the file `$NVM_DIR/default-packages`. You can add anything npm would accept as a package argument on the command line.528529```sh530# $NVM_DIR/default-packages531532rimraf533object-inspect@1.0.2534stevemao/left-pad535```536537### io.js538539> [!WARNING]540> io.js was a [fork of Node.js](https://en.wikipedia.org/wiki/Node.js#History), created in 2014 and merged back in 2015. io.js shipped v1, v2, and v3 release lines; post-merge, node.js began releasing with v4.541542If you want to install io.js:543544```sh545nvm install iojs546```547548If you want to install a new version of io.js and migrate npm packages from a previous version:549550```sh551nvm install --reinstall-packages-from=iojs iojs552```553554The same guidelines mentioned for migrating npm packages in node are applicable to io.js.555556### System Version of Node557558If you want to use the system-installed version of node, you can use the special default alias "system":559560```sh561nvm use system562nvm run system --version563```564565### Listing Versions566567If you want to see what versions are installed:568569```sh570nvm ls571```572573If you want to see what versions are available to install:574575```sh576nvm ls-remote577```578579### Setting Custom Colors580581You can set five colors that will be used to display version and alias information. These colors replace the default colors.582  Initial colors are: g b y r e583584  Color codes:585586    r/R = red / bold red587588    g/G = green / bold green589590    b/B = blue / bold blue591592    c/C = cyan / bold cyan593594    m/M = magenta / bold magenta595596    y/Y = yellow / bold yellow597598    k/K = black / bold black599600    e/W = light grey / white601602```sh603nvm set-colors rgBcm604```605606#### Persisting custom colors607608If you want the custom colors to persist after terminating the shell, export the `NVM_COLORS` variable in your shell profile. For example, if you want to use cyan, magenta, green, bold red and bold yellow, add the following line:609610```sh611export NVM_COLORS='cmgRY'612```613614#### Suppressing colorized output615616`nvm help (or -h or --help)`, `nvm ls`, `nvm ls-remote` and `nvm alias` usually produce colorized output. You can disable colors with the `--no-colors` option (or by setting the environment variable `TERM=dumb`):617618```sh619nvm ls --no-colors620nvm help --no-colors621TERM=dumb nvm ls622```623624### Restoring PATH625To restore your PATH, you can deactivate it:626627```sh628nvm deactivate629```630631### Set default node version632To set a default Node version to be used in any new shell, use the alias 'default':633634```sh635nvm alias default node # this refers to the latest installed version of node636nvm alias default 18 # this refers to the latest installed v18.x version of node637nvm alias default 18.12  # this refers to the latest installed v18.12.x version of node638```639640### Use a mirror of node binaries641To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:642643```sh644export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist645nvm install node646647NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 4.2648```649650To use a mirror of the io.js binaries, set `$NVM_IOJS_ORG_MIRROR`:651652```sh653export NVM_IOJS_ORG_MIRROR=https://iojs.org/dist654nvm install iojs-v1.0.3655656NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3657```658659Some platforms and architectures have no binary on the default host at all; see [Platforms without official binaries](#platforms-without-official-binaries).660661`nvm use` will not, by default, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to "true" to enable this behavior, which is sometimes useful for IDEs. Note that using `nvm` in multiple shell tabs with this environment variable enabled can cause race conditions.662663#### Pass Authorization header to mirror664To pass an Authorization header through to the mirror url, set `$NVM_AUTH_HEADER`665666```sh667NVM_AUTH_HEADER="Bearer secret-token" nvm install node668```669670### Platforms without official binaries671672nodejs.org does not publish a binary for every platform and architecture nvm can detect. Where it does not, `nvm install` falls back by default to compiling from source, which is slow and needs a C++ toolchain (see [Important Notes](#important-notes)); set `$NVM_NO_SOURCE_FALLBACK` to `1` to make a missing binary an error instead.673674[unofficial-builds.nodejs.org](https://unofficial-builds.nodejs.org/download/release/) ([nodejs/unofficial-builds](https://github.com/nodejs/unofficial-builds)) publishes binaries for platforms the Node.js project does not officially support. To use them, point [`$NVM_NODEJS_ORG_MIRROR`](#use-a-mirror-of-node-binaries) at it:675676```sh677export NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release678```679680| platform | binaries on nodejs.org | binaries on unofficial-builds |681| --- | --- | --- |682| `freebsd`, `openbsd` (any arch) | none | none |683| `sunos` (Solaris, illumos) | v13.x and earlier | none |684| `linux-x86` (32-bit) | v9.x and earlier | v8.16.0 through v21.x |685| `linux-armv6l` | v11.x and earlier | v8.16.0 through v22.x |686| `linux-armv7l` | v23.x and earlier | none |687| `linux-x64-musl` (Alpine) | v24.20.0+ and v26.8.0+ only | v8.16.0 and later |688| `linux-arm64-musl` (Alpine) | none | v20.20.1 and later |689| `linux-loong64` | none | v18.18.0 and later |690| `linux-riscv64` | none | v17.7.1 through v26.0.0 |691| `win-x86` (32-bit) | v22.x and earlier | none |692693Neither host is gapless, and both change over time; the `index.tab` at the root of each is authoritative. Where neither has a binary, `nvm install` compiles from source, except on non-WSL Windows, which nvm cannot build on; on FreeBSD and OpenBSD it skips the download and goes straight to source. Alpine has its own section: [Installing nvm on Alpine Linux](#installing-nvm-on-alpine-linux).694695### .nvmrc696697You can create a `.nvmrc` file containing a node version number (or any other string that `nvm` understands; see `nvm --help` for details) in the project root directory (or any parent directory).698Afterwards, `nvm use`, `nvm install`, and `nvm which` will use the version specified in the `.nvmrc` file if no version is supplied on the command line; if no `.nvmrc` is found either, they exit with status `127`. (`nvm exec` and `nvm run` follow the same `.nvmrc` lookup, but currently fall back to the active node if neither resolves &mdash; treat that fallback as undefined behavior; pass an explicit version if you need predictable scripting.) If you want the currently active version, pass `current` explicitly (e.g. `nvm which current`) &mdash; `current` is not affected by `.nvmrc`.699700For example, to make nvm default to the latest 5.9 release, the latest LTS version, or the latest node version for the current directory:701702```sh703$ echo "5.9" > .nvmrc704705$ echo "lts/*" > .nvmrc # to default to the latest LTS version706707$ echo "node" > .nvmrc # to default to the latest version708```709710[NB these examples assume a POSIX-compliant shell version of `echo`. If you use a Windows `cmd` development environment, eg the `.nvmrc` file is used to configure a remote Linux deployment, then keep in mind the `"`s will be copied leading to an invalid file. Remove them.]711712Then when you run nvm use:713714```sh715$ nvm use716Found '/path/to/project/.nvmrc' with version <5.9>717Now using node v5.9.1 (npm v3.7.3)718```719720Running nvm install will also switch over to the correct version, but if the correct node version isn't already installed, it will install it for you.721722```sh723$ nvm install724Found '/path/to/project/.nvmrc' with version <5.9>725Downloading and installing node v5.9.1...726Downloading https://nodejs.org/dist/v5.9.1/node-v5.9.1-linux-x64.tar.xz...727#################################################################################### 100.0%728Computing checksum with sha256sum729Checksums matched!730Now using node v5.9.1 (npm v3.7.3)731```732733`nvm use` et. al. will traverse directory structure upwards from the current directory looking for the `.nvmrc` file. In other words, running `nvm use` et. al. in any subdirectory of a directory with an `.nvmrc` will result in that `.nvmrc` being utilized.734735The contents of a `.nvmrc` file **must** contain precisely one `<version>` (as described by `nvm --help`) followed by a newline. `.nvmrc` files may also have comments. The comment delimiter is `#`, and it and any text after it, as well as blank lines, and leading and trailing white space, will be ignored when parsing.736737Key/value pairs using `=` are also allowed and ignored, but are reserved for future use, and may cause validation errors in the future.738739Run [`npx nvmrc`](https://npmjs.com/nvmrc) to validate an `.nvmrc` file. If that tool’s results do not agree with nvm, one or the other has a bug - please file an issue.740741### Deeper Shell Integration742743You can use [`nvshim`](https://github.com/iamogbz/nvshim) to shim the `node`, `npm`, and `npx` bins to automatically use the `nvm` config in the current directory. `nvshim` is **not** supported by the `nvm` maintainers. Please [report issues to the `nvshim` team](https://github.com/iamogbz/nvshim/issues/new).744745If you prefer a lighter-weight solution, the recipes below have been contributed by `nvm` users. They are **not** supported by the `nvm` maintainers. We are, however, accepting pull requests for more examples.746747#### Calling `nvm use` automatically in a directory with a `.nvmrc` file748749In your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`), add the following to `nvm use` whenever you enter a new directory:750751##### bash752753Put the following at the end of your `$HOME/.bashrc`:754755```bash756cdnvm() {757    command cd "$@" || return $?758    nvm_path="$(nvm_find_up .nvmrc | command tr -d '\n')"759760    # If there are no .nvmrc file, use the default nvm version761    if [[ ! $nvm_path = *[^[:space:]]* ]]; then762763        declare default_version764        default_version="$(nvm version default)"765766        # If there is no default version, set it to `node`767        # This will use the latest version on your machine768        if [ $default_version = 'N/A' ]; then769            nvm alias default node770            default_version=$(nvm version default)771        fi772773        # If the current version is not the default version, set it to use the default version774        if [ "$(nvm current)" != "${default_version}" ]; then775            nvm use default776        fi777    elif [[ -s "${nvm_path}/.nvmrc" && -r "${nvm_path}/.nvmrc" ]]; then778        declare nvm_version779        nvm_version=$(<"${nvm_path}"/.nvmrc)780781        declare locally_resolved_nvm_version782        # `nvm ls` will check all locally-available versions783        # If there are multiple matching versions, take the latest one784        # Remove the `->` and `*` characters and spaces785        # `locally_resolved_nvm_version` will be `N/A` if no local versions are found786        locally_resolved_nvm_version=$(nvm ls --no-colors "${nvm_version}" | command tail -1 | command tr -d '\->*' | command tr -d '[:space:]')787788        # If it is not already installed, install it789        # `nvm install` will implicitly use the newly-installed version790        if [ "${locally_resolved_nvm_version}" = 'N/A' ]; then791            nvm install "${nvm_version}";792        elif [ "$(nvm current)" != "${locally_resolved_nvm_version}" ]; then793            nvm use "${nvm_version}";794        fi795    fi796}797798alias cd='cdnvm'799cdnvm "$PWD" || exit800```801802This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.803804##### zsh805806This shell function will install (if needed) and `nvm use` the specified Node version when an `.nvmrc` is found, and `nvm use default` otherwise.807808Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you enter a directory that contains an809`.nvmrc` file with a string telling nvm which node to `use`:810811```zsh812# place this after nvm initialization!813autoload -U add-zsh-hook814815load-nvmrc() {816  local nvmrc_path817  nvmrc_path="$(nvm_find_nvmrc)"818819  if [ -n "$nvmrc_path" ]; then820    local nvmrc_node_version821    nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")822823    if [ "$nvmrc_node_version" = "N/A" ]; then824      nvm install825    elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then826      nvm use827    fi828  elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then829    echo "Reverting to nvm default version"830    nvm use default831  fi832}833834add-zsh-hook chpwd load-nvmrc835load-nvmrc836```837838After saving the file, run `source ~/.zshrc` to reload the configuration with the latest changes made.839840##### fish841842This requires that you have [bass](https://github.com/edc/bass) installed.843```fish844# ~/.config/fish/functions/nvm.fish845function nvm846  bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv847end848849# ~/.config/fish/functions/nvm_find_nvmrc.fish850function nvm_find_nvmrc851  bass source ~/.nvm/nvm.sh --no-use ';' nvm_find_nvmrc852end853854# ~/.config/fish/functions/load_nvm.fish855function load_nvm --on-variable="PWD"856  set -l default_node_version (nvm version default)857  set -l node_version (nvm version)858  set -l nvmrc_path (nvm_find_nvmrc)859  if test -n "$nvmrc_path"860    set -l nvmrc_node_version (nvm version (cat $nvmrc_path))861    if test "$nvmrc_node_version" = "N/A"862      nvm install (cat $nvmrc_path)863    else if test "$nvmrc_node_version" != "$node_version"864      nvm use $nvmrc_node_version865    end866  else if test "$node_version" != "$default_node_version"867    echo "Reverting to default Node version"868    nvm use default869  end870end871872# ~/.config/fish/config.fish873# You must call it on initialization or listening to directory switching won't work874load_nvm > /dev/stderr875```876877## Running Tests878879Tests are written in [Urchin]. Install Urchin (and other dependencies) like so:880881    npm install882883There are slow tests and fast tests. The slow tests do things like install node884and check that the right versions are used. The fast tests fake this to test885things like aliases and uninstalling. From the root of the nvm git repository,886run the fast tests like this:887888    npm run test/fast889890Run the slow tests like this:891892    npm run test/slow893894Run all of the tests like this:895896    npm test897898`npm run test/fast` runs `make` inside a clean environment (`env -i ... bash -lc`), so `node` must be on the `PATH` of a fresh login `bash` shell.899If `node` is only available through `nvm` in your current shell, it fails with "Did you forget to run `npm install` after cloning the repo?", even after a successful `npm install`.900In that case, run `make` directly from the root of the nvm git repository, choosing the test suite and shell:901902    make TEST_SUITE=fast test-zsh903904Nota bene: Avoid running nvm while the tests are running.905906## Environment variables907908nvm exposes the following environment variables:909910- `NVM_DIR` - nvm's installation directory.911- `NVM_BIN` - where node, npm, and global packages for the active version of node are installed.912- `NVM_INC` - node's include file directory (useful for building C/C++ addons for node).913- `NVM_CD_FLAGS` - used to maintain compatibility with zsh.914- `NVM_RC_VERSION` - version from .nvmrc file if being used.915916Additionally, nvm modifies `PATH` when changing versions, along with `MANPATH` wherever a `manpath` command exists, and `NODE_PATH`, if present.917918The following environment variables can be set to configure `nvm install`:919920- `NVM_NO_SOURCE_FALLBACK` - when `1`, a failed binary download aborts instead of silently falling back to a (much slower) from-source compile; the persistent equivalent of the `-b` flag, and mutually exclusive with `-s`.921- `NVM_INSTALL_LOCK_TIMEOUT` - seconds to wait for a concurrent install of the same version to finish before giving up (default `600`). On timeout, nvm prints the lock path so a lock left behind by a killed install can be removed.922- `NVM_INSTALL_LOCK_STALE` - minutes after which an install lock is assumed abandoned and stolen automatically; `0` (the default) never steals.923924`nvm install <version>` takes a per-version advisory lock (a directory under `$NVM_DIR/.cache/locks`), so two shells installing the same version at once cannot corrupt its version directory; installs of *different* versions never block each other.925926927## Bash Completion928929To activate, you need to source `bash_completion`:930931```sh932[[ -r $NVM_DIR/bash_completion ]] && \. $NVM_DIR/bash_completion933```934935Put the above sourcing line just below the sourcing line for nvm in your profile (`.bashrc`, `.bash_profile`).936937### Usage938939nvm:940941> `$ nvm` <kbd>Tab</kbd>942```sh943alias               deactivate          install             list-remote         reinstall-packages  uninstall           version944cache               exec                install-latest-npm  ls                  run                 unload              version-remote945current             help                list                ls-remote           unalias             use                 which946```947948nvm alias:949950> `$ nvm alias` <kbd>Tab</kbd>951```sh952default      iojs         lts/*        lts/argon    lts/boron    lts/carbon   lts/dubnium  lts/erbium   node         stable       unstable953```954955956> `$ nvm alias my_alias` <kbd>Tab</kbd>957```sh958v10.22.0       v12.18.3      v14.8.0959```960961nvm use:962> `$ nvm use` <kbd>Tab</kbd>963964```965my_alias        default        v10.22.0       v12.18.3      v14.8.0966```967968nvm uninstall:969> `$ nvm uninstall` <kbd>Tab</kbd>970971```972my_alias        default        v10.22.0       v12.18.3      v14.8.0973```974975## Compatibility Issues976977`nvm` will encounter some issues if you have some non-default settings set. (see [#606](https://github.com/nvm-sh/nvm/issues/606))978The following are known to cause issues:979980Inside `~/.npmrc`:981982```sh983prefix='some/path'984```985986Environment Variables:987988```sh989$NPM_CONFIG_PREFIX990$PREFIX991```992993Shell settings:994995```sh996set -e997```998999## Installing nvm on Alpine Linux10001001In order to provide the best performance (and other optimizations), nvm will download and install pre-compiled binaries for Node (and npm) when you run `nvm install X`. The Node project compiles, tests and hosts/provides these pre-compiled binaries which are built for mainstream/traditional Linux distributions (such as Debian, Ubuntu, [CentOS](https://www.centos.org), [RedHat](https://www.redhat.com) et al).10021003[Alpine Linux](https://www.alpinelinux.org), unlike mainstream/traditional Linux distributions, is based on [BusyBox](https://www.busybox.net/), a very compact (~5MB) Linux distribution. BusyBox (and thus Alpine Linux) uses a different C/C++ stack to most mainstream/traditional Linux distributions - [musl](https://www.musl-libc.org/). This makes binary programs built for such mainstream/traditional distributions incompatible with Alpine Linux, so on `x64` and `arm64` nvm requests a `musl` build instead. nodejs.org publishes those only for some recent `x64` releases, so for anything else the download 404s and `nvm install X` falls back to compiling from source, unless you point it at a mirror that has one (see [Platforms without official binaries](#platforms-without-official-binaries)).10041005There is a `-s` flag for `nvm install` which requests nvm download Node source and compile it locally.10061007If installing nvm on Alpine Linux *is* still what you want or need to do, you should be able to achieve this by running the following from your Alpine Linux shell, depending on which version you are using:10081009### Alpine Linux 3.13+1010```sh1011apk add -U curl bash ca-certificates openssl ncurses coreutils python3 make gcc g++ libgcc linux-headers grep util-linux binutils findutils1012curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash1013```10141015### Alpine Linux 3.5 - 3.121016```sh1017apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils1018curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash1019```10201021_Note: Alpine 3.5 can only install NodeJS versions up to v6.9.5, Alpine 3.6 can only install versions up to v6.10.3, Alpine 3.7 installs versions up to v8.9.3, Alpine 3.8 installs versions up to v8.14.0, Alpine 3.9 installs versions up to v10.19.0, Alpine 3.10 installs versions up to v10.24.1, Alpine 3.11 installs versions up to v12.22.6, Alpine 3.12 installs versions up to v12.22.12, Alpine 3.13 & 3.14 install versions up to v14.20.0, Alpine 3.15 & 3.16 install versions up to v16.16.0 (**These are all versions on the main branch**). Alpine 3.5 - 3.12 required the package [`python2`](https://www.python.org/) to build NodeJS, as they are older versions to build. Alpine 3.13+ requires `python3` to successfully build newer NodeJS versions, but you can use `python2` with Alpine 3.13+ if you need to build versions of node supported in Alpine 3.5 - 3.15, you just need to specify what version of NodeJS you need to install in the package install script._10221023The Node project now publishes an official `linux-x64-musl` binary for some recent releases (v24.20.0+ and v26.8.0+; no v25 release has one). There is no official `arm64` musl binary.10241025As a potential alternative, [@mhart](https://github.com/mhart) (a Node contributor) has some [Docker images for Alpine Linux with Node and optionally, npm, pre-installed](https://github.com/mhart/alpine-node).10261027<a id="removal"></a>1028## Uninstalling / Removal10291030### Manual Uninstall10311032To remove `nvm` manually, execute the following:10331034First, use `nvm unload` to remove the nvm command from your terminal session and delete the installation directory:10351036```sh1037$ nvm_dir="${NVM_DIR:-~/.nvm}"1038$ nvm unload1039$ rm -rf "$nvm_dir"1040```10411042Edit `~/.bashrc` (or other shell resource config) and remove the lines below:10431044```sh1045export NVM_DIR="$HOME/.nvm"1046[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm1047[[ -r $NVM_DIR/bash_completion ]] && \. $NVM_DIR/bash_completion1048```10491050## Docker For Development Environment10511052To make development and testing work easier we supply a Dockerfile for development usage. It's based on an Ubuntu base image prepared with essential and useful tools for `nvm` development. To build the docker image of the environment, do a Docker build at the root of `nvm` repository:10531054```sh1055$ docker build -t nvm-dev .1056```10571058This will package your current nvm working copy with our pre-defined development environment into a Docker image named `nvm-dev`. After the build you should see it appear in the list of images:10591060```sh1061$ docker images10621063REPOSITORY         TAG                 IMAGE ID            CREATED             SIZE1064nvm-dev            latest              9ca4c57a97d8        7 days ago          650 MB1065```10661067To start and enter a container based on this image:10681069```sh1070$ docker run -h nvm-dev -it nvm-dev10711072nvm@nvm-dev:~/.nvm$1073```10741075It takes several minutes to build the image and the image size is about 650MB, so it's not suitable for production usage.10761077For more information and documentation about Docker, please refer to its [official website][docker-www] and [documentation][docker-docs]:10781079## Problems10801081  - If you try to install a node version and the installation fails, be sure to run `nvm cache clear` to delete cached node downloads, or you might get an error like the following:10821083    curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.10841085  - Where's my `sudo node`? Check out [#43](https://github.com/nvm-sh/nvm/issues/43)10861087  - After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source:10881089```sh1090nvm install -s 0.8.61091```10921093  - If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node `PATH` is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/nvm-sh/nvm/issues/658))10941095## macOS Troubleshooting10961097**nvm node version not found in [vim](https://www.vim.org) shell**10981099If you set node version to a version other than your system node version `nvm use 6.2.1` and open vim and run `:!node -v` you should see `v6.2.1` if you see your system version `v0.12.7`. You need to run:11001101```shell1102sudo chmod ugo-x /usr/libexec/path_helper1103```11041105More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).11061107**nvm is not compatible with the npm config "prefix" option**11081109Some solutions for this issue can be found [here](https://github.com/nvm-sh/nvm/issues/1245)11101111There is one more edge case causing this issue, and that's a **mismatch between the `$HOME` path and the user's home directory's actual name**.11121113You have to make sure that the user directory name in `$HOME` and the user directory name you'd see from running `ls /Users/` **are capitalized the same way** ([See this issue](https://github.com/nvm-sh/nvm/issues/2261)).11141115To change the user directory and/or account name follow the instructions [here](https://support.apple.com/en-us/HT201548)11161117[1]: https://github.com/nvm-sh/nvm.git1118[2]: https://github.com/nvm-sh/nvm/blob/v0.40.8/install.sh1119[3]: https://github.com/nvm-sh/nvm/actions/workflows/tests-fast.yml1120[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.40.81121[Urchin]: https://git.sdf.org/tlevine/urchin1122[Fish]: https://fishshell.com11231124**Homebrew makes zsh directories insecure**11251126```shell1127zsh compinit: insecure directories, run compaudit for list.1128Ignore insecure directories and continue [y] or abort compinit [n]? y1129```11301131Homebrew causes insecure directories like `/usr/local/share/zsh/site-functions` and `/usr/local/share/zsh`. This is **not** an `nvm` problem - it is a homebrew problem. Refer [here](https://github.com/zsh-users/zsh-completions/issues/680) for some solutions related to the issue.11321133**Macs with Apple Silicon chips**11341135Experimental support for the Apple Silicon chip architecture was added in node.js v15.3 and full support was added in v16.0.1136Because of this, if you try to install older versions of node as usual, you will probably experience either compilation errors when installing node or out-of-memory errors while running your code.11371138So, if you want to run a version prior to v16.0 on an Apple Silicon Mac, it may be best to compile node targeting the `x86_64` Intel architecture so that [Rosetta 2](https://support.apple.com/en-us/HT211861) can translate the `x86_64` processor instructions to ARM-based Apple Silicon instructions.1139Here's what you will need to do:11401141- Install Rosetta, if you haven't already done so11421143  ```sh1144  $ softwareupdate --install-rosetta1145  ```11461147  You might wonder, "how will my Apple Silicon Mac know to use Rosetta for a version of node compiled for an Intel chip?".1148  If an executable contains only Intel instructions, macOS will automatically use Rosetta to translate the instructions.11491150- Open a shell that's running using Rosetta11511152  ```sh1153  $ arch -x86_64 zsh1154  ```11551156  Note: This same thing can also be accomplished by finding the Terminal or [iTerm](https://iterm2.com) App in Finder, right clicking, selecting "Get Info", and then checking the box labeled "Open using Rosetta".11571158  Note: This terminal session is now running in `zsh`.1159  If `zsh` is not the shell you typically use, `nvm` may not be `source`'d automatically like it probably is for your usual shell through your dotfiles.1160  If that's the case, make sure to source `nvm`.11611162  ```sh1163  $ source "${NVM_DIR}/nvm.sh"1164  ```11651166- Install whatever older version of node you are interested in. Let's use 12.22.1 as an example.1167  This will fetch the node source code and compile it, which will take several minutes.11681169  ```sh1170  $ nvm install v12.22.1 --shared-zlib1171  ```11721173  Note: You're probably curious why `--shared-zlib` is included.1174  There's a bug in recent versions of Apple's system [`clang`](https://clang.llvm.org/) compiler.1175  If one of these broken versions is installed on your system, the above step will likely still succeed even if you didn't include the `--shared-zlib` flag.1176  However, later, when you attempt to `npm install` something using your old version of node.js, you will see `incorrect data check` errors.1177  If you want to avoid the possible hassle of dealing with this, include that flag.1178  For more details, see [this issue](https://github.com/nodejs/node/issues/39313) and [this comment](https://github.com/nodejs/node/issues/39313#issuecomment-902395576)11791180- Exit back to your native shell.11811182  ```sh1183  $ exit1184  $ arch1185  arm641186  ```11871188  Note: If you selected the box labeled "Open using Rosetta" rather than running the CLI command in the second step, you will see `i386` here.1189  Unless you have another reason to have that box selected, you can deselect it now.11901191- Check to make sure the architecture is correct. `x64` is the abbreviation for `x86_64`, which is what you want to see.11921193  ```sh1194  $ node -p process.arch1195  x641196  ```11971198Now you should be able to use node as usual.11991200## WSL Troubleshooting12011202If you've encountered this error on WSL-2:12031204  ```sh1205  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash1206  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current1207                                  Dload  Upload  Total   Spent    Left  Speed1208  0     0    0     0    0     0      0      0 --:--:--  0:00:09 --:--:--     0curl: (6) Could not resolve host: raw.githubusercontent.com1209  ```12101211It may be due to your antivirus, VPN, or other reasons.12121213Where you can `ping 8.8.8.8` while you can't `ping google.com`121412151216This could simply be solved by running this in your root directory:12171218  ```sh1219  sudo rm /etc/resolv.conf1220  sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'1221  sudo bash -c 'echo "[network]" > /etc/wsl.conf'1222  sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'1223  sudo chattr +i /etc/resolv.conf1224  ```12251226This deletes your `resolv.conf` file that is automatically generated when you run WSL, creates a new file and puts `nameserver 8.8.8.8`, then creates a `wsl.conf` file and adds `[network]` and `generateResolveConf = false` to prevent auto-generation of that file.12271228You can check the contents of the file by running:12291230  ```sh1231  cat /etc/resolv.conf1232  ```12331234## Maintainers12351236Currently, the sole maintainer is [@ljharb](https://github.com/ljharb) - more maintainers are quite welcome, and we hope to add folks to the team over time. [Governance](./GOVERNANCE.md) will be re-evaluated as the project evolves.12371238## Project Support12391240Only the latest version (v0.40.8 at this time) is supported.12411242## Enterprise Support12431244If you are unable to update to the latest version of `nvm`, our [partners](https://openjsf.org/ecosystem-sustainability-program) provide commercial security fixes for all unsupported versions:12451246  - [HeroDevs Never-Ending Support](https://www.herodevs.com/support?utm_source=OpenJS&utm_medium=Link&utm_campaign=nvm_openjs)12471248## License12491250See [LICENSE.md](./LICENSE.md).12511252## Copyright notice12531254Copyright [OpenJS Foundation](https://openjsf.org) and `nvm` contributors. All rights reserved. The [OpenJS Foundation](https://openjsf.org) has registered trademarks and uses trademarks.  For a list of trademarks of the [OpenJS Foundation](https://openjsf.org), please see our [Trademark Policy](https://trademark-policy.openjsf.org/) and [Trademark List](https://trademark-list.openjsf.org/).  Trademarks and logos not indicated on the [list of OpenJS Foundation trademarks](https://trademark-list.openjsf.org) are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.1255[The OpenJS Foundation](https://openjsf.org/) | [Terms of Use](https://terms-of-use.openjsf.org/) | [Privacy Policy](https://privacy-policy.openjsf.org/) | [Bylaws](https://bylaws.openjsf.org/) | [Code of Conduct](https://code-of-conduct.openjsf.org) | [Trademark Policy](https://trademark-policy.openjsf.org/) | [Trademark List](https://trademark-list.openjsf.org/) | [Cookie Policy](https://www.linuxfoundation.org/cookies/)12561257<!-------------------------------------------------------------------->1258[docker-docs]: https://docs.docker.com/1259[docker-www]: https://www.docker.com/