DEV Community

Cover image for How to Install NVM on macOS
Rakshit Nayak
Rakshit Nayak

Posted on Edited on

How to Install NVM on macOS

Setting Up NVM on macOS (One-Time Setup)

If you're a developer working with Node.js, managing multiple versions of Node across different projects can get messy. That's where NVM (Node Version Manager) comes in a handy tool that lets you easily install, switch, and manage multiple versions of Node.js.

In this guide, we’ll walk you through a one-time setup of NVM on your macOS system.


Step 1: Open Your Terminal

By default, macOS uses the Zsh shell, so we’ll work with that.

Open the Terminal app. You can find it via Spotlight (Cmd + Space, then type Terminal).

Open Terminal


Step 2: Go to Your Home Directory

Make sure you're in your user’s home directory:
pwd

List all files (including hidden ones) to check if .zshrc already exists:

ls -a
Enter fullscreen mode Exit fullscreen mode

Step 3: Create .zshrc If It Doesn’t Exist

touch .zshrc
Enter fullscreen mode Exit fullscreen mode

This file is where you'll store shell configurations, including NVM-related settings.


Step 4: Install NVM

Use the official installation script from the NVM GitHub repository:
https://github.com/nvm-sh/nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Step 5: Apply the Configuration

Once installed, you need to reload your shell configuration so NVM is available in the terminal:

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

To confirm everything went smoothly, run:

nvm --version
Enter fullscreen mode Exit fullscreen mode

Top comments (0)