Skip to the content.

Managing Node.js Versions with nvm

Check Current Versions

node --version
npm --version

Installing nvm

If you don’t have nvm installed, you can install it using:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Restart your terminal after installation.

Basic nvm Commands

List Installed Node.js Versions

nvm ls

List Available Node.js Versions

nvm ls-remote

Install a Specific Version

nvm install <version>  # e.g., nvm install 18.18.0

Switch to a Specific Version

nvm use <version>      # e.g., nvm use 18.18.0

Set Default Version

This will be used in new terminal sessions:

nvm alias default <version>  # e.g., nvm alias default 18.18.0

Check Current Version

node --version
npm --version

Example Workflow

  1. Check current version: node --version
  2. List installed versions: nvm ls
  3. Install a new version: nvm install 18.18.0
  4. Switch to it: nvm use 18.18.0
  5. Make it default: nvm alias default 18.18.0

Notes