Install nvm
curl -o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh
| bash
Install nvm with curl
wget -qO-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh
| bash
Install nvm with wget
nvm --version
Show the nvm version
command -v nvm
Check that nvm is loaded
Prints nvm when the function exists; empty output means the
shell never sourced nvm.sh.
source ~/.bashrc
Reload the shell profile after install
Use ~/.zshrc for zsh. Or just open a new terminal.
PROFILE=/dev/null
Stop the installer editing your profile
Set it in front of the install script's bash, then add the
source lines yourself.
XDG_CONFIG_HOME
Keep nvm files under $XDG_CONFIG_HOME/nvm
git fetch --tags origin
Update a git-clone install (then check out the tag)
Install and use
nvm install <version>
Install a Node version
nvm install --lts
Install the newest LTS
nvm install node
Install the latest release
nvm install
Install the version from .nvmrc
nvm use <version>
Use a version in this shell
nvm use --lts
Use the newest LTS
nvm use node
Use the latest release
nvm use system
Use the system-installed Node
nvm use default
Return to the default version
nvm use
Use the version from .nvmrc
nvm install --lts=<name>
Install a named LTS line
nvm install <version> --latest-npm
Upgrade npm to the newest it supports
nvm install-latest-npm
Upgrade npm in the active version
nvm install <version>
--reinstall-packages-from=<old>
Install and copy global packages
nvm install -s <version>
Compile from source
nvm install <version> --offline
Install from cached files only
Aliases and defaults
nvm alias default <version>
Set the version new shells start with
nvm alias default node
Default to whatever is latest
nvm alias default lts/*
Default to the newest LTS
nvm alias <name> <version>
Create your own alias
nvm alias
List all aliases
nvm unalias <name>
Delete an alias
nvm use lts/<name>
Use a named LTS line, such as lts/iron
LTS aliases are managed by nvm under $NVM_DIR/alias/lts; do
not edit them.
nvm deactivate
Undo nvm's PATH changes in this shell
nvm unload
Remove nvm from this shell
.nvmrc and packages
echo "lts/*" > .nvmrc
Pin the project to the newest LTS
node -v > .nvmrc
Pin the project to the running version
nvm install && nvm use
Install then use the pinned version
nvm reinstall-packages <version>
Copy that version's global packages here
Installs into the active version; it does not touch npm
itself.
npx nvmrc
Validate the .nvmrc file
$NVM_DIR/default-packages
File of packages installed with every new Node
One package per line, anything npm accepts, such as rimraf or
object-inspect@1.0.2.
.nvmrc contents
Value
Meaning
20
Any installed or installable 20.x
20.11.1
That exact release
lts/*
Newest LTS
lts/iron
A named LTS line
node
Latest release
nvm looks for .nvmrc upward through parent directories and exits
with status 127 if it finds none. Lines starting with # are
comments.
Shell integration
export NVM_DIR="$HOME/.nvm"
Where nvm lives
[ -s "$NVM_DIR/nvm.sh" ] && .
"$NVM_DIR/nvm.sh"
Load nvm in your shell profile
[ -s "$NVM_DIR/nvm.sh" ] && .
"$NVM_DIR/nvm.sh" --no-use
Load nvm without activating the default
Skips the default-version setup, which makes shell startup
faster. Run nvm use when you need Node.
NVM_NODEJS_ORG_MIRROR=<url> nvm install
<version>
Install from a mirror
NVM_NO_SOURCE_FALLBACK=1
Error instead of compiling when no binary exists
NVM_SYMLINK_CURRENT=true
Keep a current symlink for IDEs
Auto-switching on cd is a community recipe (a cd wrapper in
bash, a chpwd hook in zsh), not a built-in feature.
Slow shell startup is usually nvm.sh being sourced eagerly. Add
--no-use, or load it lazily on first use of nvm, node or npm.