$linuxjunkies
>

nvm(1)

Node Version Manager (nvm) allows you to install and switch between multiple versions of Node.js and npm.

UbuntuDebianFedoraArch

Synopsis

nvm [COMMAND] [OPTIONS]

Description

nvm is a bash script that manages Node.js versions on a per-user basis. It installs Node.js versions into isolated directories, letting you switch between them without affecting your system Node.js installation or other users' environments.

After installing nvm, new shell sessions automatically have access to the nvm command. You can install multiple Node versions, set a default version, and switch versions on-demand using simple commands.

Common options

FlagWhat it does
install <VERSION>Download and install a specific Node version (e.g., nvm install 18.0.0 or nvm install node for latest)
use <VERSION>Activate a Node version in the current shell session
alias <NAME> <VERSION>Create an alias for a Node version (e.g., nvm alias myproject 16.13.0)
alias default <VERSION>Set the default Node version for new shell sessions
listShow all installed Node versions; current version marked with arrow
list-remoteList all available Node versions available for installation
uninstall <VERSION>Remove an installed Node version and its npm packages
currentDisplay the currently active Node version
run <VERSION> [ARGS]Execute a command with a specific Node version without switching
which <VERSION>Show the path to an installed Node version's executable

Examples

Download and install Node.js version 18.12.0

nvm install 18.12.0

Install the latest stable version of Node.js

nvm install node

Activate Node version 16.13.0 in the current shell session

nvm use 16.13.0

Display all installed Node versions with the current one highlighted

nvm list

Set Node 18.12.0 as the default version for all new shells

nvm alias default 18.12.0

Run app.js using Node version 14.21.0 without switching versions

nvm run 14.21.0 app.js

Remove Node version 16.13.0 and all its associated npm packages

nvm uninstall 16.13.0

Create a named alias 'production' for Node version 18.12.0

nvm alias production 18.12.0

Related commands