thumbnail

# Guide to Installing Node.js via NVM on Windows, Linux, and Mac

Table of Contents

Node.js is an open-source platform used to build web applications, servers, and real-time apps. It is written in JavaScript, the programming language primarily used in web applications.

NVM stands for Node.js Version Manager, a tool that helps you manage multiple Node.js versions on the same system. This is useful when you need different Node.js versions for different projects.

In this article, we will walk through installing Node.js via NVM on every environment: Windows, Linux, and Mac.

Install NVM on Windows

You can install nvm on Windows through choco (learn about choco if you have not used it before). Open an elevated PowerShell window, then run:

# Install Chocolatey
choco install nvm
# Restart PowerShell
Restart-Powershell

After restarting PowerShell, verify that NVM installed successfully with:

nvm --version

If the command returns a version number, you are all set.

Install NVM on Linux

To install NVM on Linux, open a terminal and run:

# Install curl if it is missing
sudo apt install curl
# Install NVM via curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

After installation, check that NVM is available:

nvm --version

If the command returns a version number, the installation worked.

Install NVM on Mac

To install NVM on macOS, open a terminal and run:

# Install Homebrew if you do not have it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Install NVM
brew install nvm

After installation, verify NVM with:

nvm --version

If you see a version number, the setup is complete.

Install Node.js via NVM

Install Node.js through NVM with:

nvm install [version]

For example, to install Node.js 16.13.0:

nvm install 16.13.0

After installation, activate that version:

nvm use [version]

For example, to switch to Node.js 16.13.0:

Terminal window
nvm use 16.13.0

Conclusion

NVM is a handy tool that lets you manage multiple Node.js versions on the same system. With it, you can install, switch, and manage any version you need.

Additional NVM commands

Beyond the basic commands above, NVM offers extra commands that make version management easier. Common ones include:

  • nvm list to show every Node.js version currently installed.
  • nvm ls-remote to list every Node.js version available for installation.
  • nvm uninstall [version] to remove a Node.js version.
  • nvm alias [alias] [version] to create an alias for a Node.js version.

You can learn more on the official NVM repository (https://github.com/nvm-sh/nvm).

My avatar

Thanks for reading! If this was helpful:

  • Share the post/blog with a teammate or friend.
  • Subscribe to get new posts by email.
  • Send feedback or questions — I read every note and usually reply quickly.

Happy coding!


More Posts

Comments