NVM (Node Version Manager) – The Ultimate Guide

Node Version Manager (NVM) is a powerful tool that allows developers to manage multiple Node.js versions on their system. Whether you’re working on different projects requiring different Node.js versions or simply want to stay up-to-date with the latest releases, NVM makes version management seamless. In this guide, we’ll explore how to install NVM, use essential commands, and maximize its benefits.

Installing NVM on Linux and macOS

  • Open your terminal and run the following command:
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
  • Reload your shell configuration file:
source ~/.bashrc  # or source ~/.zshrc if using Zsh
  • Verify the installation:
command -v nvm

If the command outputs nvm, it means NVM is installed successfully.

Installing Node Version Manager on Windows

For Windows users, the best way to install NVM is through nvm-windows:

  • Download the latest release from nvm-windows GitHub.
  • Run the installer and follow the setup instructions.
  • After installation, open Command Prompt and verify it:
nvm version

1. Check Installed Node.js Versions

nvm list

This will display all Node.js versions currently installed on your system.

2. Install a Specific Node.js Version

nvm install 18

Replace 18 with the desired Node.js version.

3. Use a Specific Node.js Version

nvm use 18

This switches the active Node.js version to 18.

4. Set a Default Node.js Version

nvm alias default 18

This ensures Node.js 18 is used by default when opening a new terminal session.

5. List Available Versions for Installation

nvm list-remote

This shows all Node.js versions available for download.

Node Version Manager is an essential tool for any JavaScript or Node.js developer, making it easy to switch between different Node.js versions without conflicts. By following this guide, you can install NVM, manage versions efficiently, and ensure compatibility across various projects. So, start using it today and take control of your Node.js environment!

Check more our articles here