Install, uninstall or switch between Node.js versions. Supports version numbers like "12.8" or "v16.13.1", and labels like "stable", "system", etc.
# To install a specific version of Node.js:
nvm install <node_version>
# To use a specific version of Node.js in the current shell:
nvm use <node_version>
# To set the default Node.js version:
nvm alias default <node_version>
# To list all available Node.js versions and highlight the default one:
nvm list
# To uninstall a given Node.js version:
nvm uninstall <node_version>
# To launch the REPL of a specific version of Node.js:
nvm run <node_version> --version
# To execute a script in a specific version of Node.js:
nvm exec <node_version> node <app.js>
# ---
# To list latest available (remote) Node.js versions:
nvm ls-remote
# To install the latest Node.js LTS (Long-term support) version:
nvm install --lts
# To install a Node.js release by its code name:
nvm install gallium
# To install the latest Node.js version:
nvm install node
# To use the latest Node.js LTS (Long-term support) version:
nvm use --lts
# To make nvm default to a specific Node.js version for a project:
echo "14" > .nvmrc
# To make nvm default to the latest Node.js version for a project:
echo "node" > .nvmrc
# To make nvm default to the latest Node.js LTS (Long-term support) version for a project:
echo "lts/*" > .nvmrc
# To get the latest LTS version of node and migrate your existing installed packages:
nvm install --lts --reinstall-packages-from=current
# To get the latest supported npm version on the current node version:
nvm install-latest-npm
# If you want to use the system-installed version of Node.js, you can use the special default alias "system":
nvm use system
nvm run system --version
# To install the current default/active version of node and reinstall it (in this case, node v16):
nvm deactivate
nvm uninstall 16
nvm install 16
# To always default to the latest available node version on a shell:
nvm alias default node