To resolve this issue, ensure that nvm is properly set up in your shell configuration. Since you are using zsh, add the following lines to your .zshrc file:

brew upgrade
brew install nvm
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/nvm.sh" ] && \. "$(brew --prefix nvm)/nvm.sh"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && \. "$(brew --prefix nvm)/etc/bash_completion.d/nvm"' >> ~/.zshrc
source ~/.zshrc

After running these commands, nvm should be set up correctly. You can verify the installation by checking the nvm version:

$ nvm --version
Answer from hemant jangra on Stack Overflow
Top answer
1 of 4
113

To resolve this issue, ensure that nvm is properly set up in your shell configuration. Since you are using zsh, add the following lines to your .zshrc file:

brew upgrade
brew install nvm
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/nvm.sh" ] && \. "$(brew --prefix nvm)/nvm.sh"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && \. "$(brew --prefix nvm)/etc/bash_completion.d/nvm"' >> ~/.zshrc
source ~/.zshrc

After running these commands, nvm should be set up correctly. You can verify the installation by checking the nvm version:

$ nvm --version
2 of 4
13

Looking at the warning which you added in your question, I surmise that nvm is installed on your machine but may not have been setup properly. Nevertheless, adding full steps for you to verify which one you missed and fix the same.

1. Confirm nvm is installed

Before making changes, check if nvm exists:

# confirm nvm is installed
$ brew list | grep nvm
# if the above doesn't return anything, install nvm
$ brew install nvm

2. Ensure your system is in good shape

Sometimes Homebrew issues prevent nvm from working properly. For that run:

$ brew doctor
# If you see any warnings, follow the suggested fixes and 
# rerun brew doctor until everything looks good. 

3. Create the nvm directory (if missing)

$ mkdir -p ~/.nvm

4. Add nvm to your shell configuration

Manually add these lines to ~/.zshrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix nvm)/nvm.sh" ] && . "$(brew --prefix nvm)/nvm.sh"
[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && . "$(brew --prefix nvm)/etc/bash_completion.d/nvm"

Save the file and reload the configuration:

$ source ~/.zshrc

5. Verify and Restart

Check if nvm is now working:

$ nvm -v

If you still get an error, restart your terminal and try again. Sometimes failing to do this might also lead to issues.

🌐
Homebrew
formulae.brew.sh › formula › nvm
nvm — Homebrew Formulae
Manage multiple Node.js versions · https://github.com/nvm-sh/nvm · License: MIT · Formula JSON API: /api/formula/nvm.json · Formula code: nvm.rb on GitHub · Bottle (binary package) installation support provided.
Discussions

Nvm or homebrew for Node install
I use homebrew to install nvm then install node via nvm ¯\(ツ)/¯ More on reddit.com
🌐 r/webdev
34
19
April 12, 2023
The next generation node version manager
Is it compatible with existing .nvmrc files? As in, if someone installed use-node but the project has a .nvmrc, could it read that version from there instead of package.json? More on reddit.com
🌐 r/node
19
41
December 8, 2022
If I'm going to use Homebrew, does that mean I should just install EVERYTHING with Homebrew from the very beginning?
I would use nvm for Node but yes. When I setup a Mac, I do everything from homebrew. Keep one package manager if you can. More on reddit.com
🌐 r/node
29
38
December 1, 2020
Is there no best practice way to install Node?
Best practice is to use nvm or n. https://github.com/creationix/nvm/ https://github.com/tj/n I prefer nvm. More on reddit.com
🌐 r/node
12
1
July 25, 2018
🌐
Catalin's Tech
catalins.tech › node-version-manager-macos
Install and Use Node Version Manager (NVM) on macOS
March 11, 2024 - This article teaches you how to install Node Version Manager on macOS and the most common & useful NVM commands.
🌐
Reddit
reddit.com › r/webdev › nvm or homebrew for node install
r/webdev on Reddit: Nvm or homebrew for Node install
April 12, 2023 -

I come across this decision every time I get a new Mac laptop/computer.

I like nvm, node version manager, because it allows me to install multiple versions of node/npm in case I need to switch within different versions.

Does homebrew offer the same? Are there other install recommendations for Mac?

The need to switch node versions does come up when asked to work on another project that is “stuck” on an older version of node due to outdated packages that no one wants to maintain but is still used in the project.

April 12, 2023 Update Thanks for all the great recommendations and insight. I decided to use fnm for my own preference at this time, but all alternatives seem great in their own way. Here is a great article from Honeybadger comparing many node environment managers: https://www.honeybadger.io/blog/node-environment-managers

🌐
Collabnix
collabnix.com › how-to-install-and-configure-nvm-on-mac-os
How to install and Configure NVM on Mac OS - Collabnix
January 6, 2023 - nvm (Node Version Manager) is a tool that allows you to install and manage multiple versions of Node.js on your Mac. nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular ...
🌐
daily.dev
daily.dev › home › blog › webdev › how to use multiple node versions with nvm on macos - node version manager
How To Use Multiple Node Versions With NVM On MacOS - Node Version Manager
November 1, 2021 - After installing the Node version ... version of Node by running nvm use --lts. The Node Version Manager is a handy tool to switch between Node versions....
🌐
DEV Community
dev.to › mesonu › how-to-install-and-manage-multiple-nodejs-versions-on-macos-using-nvm-2jfh
How to Install and Manage Multiple Node.js Versions on macOS Using NVM - DEV Community
June 27, 2024 - NVM is a version manager for Node.js, designed to simplify the installation and management of multiple Node.js versions on a single machine.
Find elsewhere
🌐
Julio Trigo
juliotrigo.com › articles › installing-nodejs-and-npm-on-a-mac
Installing Node.js and npm on a Mac | Julio Trigo
I decided to go with NVM (Node Version Manager), which seems to be widely adopted and it’s also the one I was familiar with.
🌐
Nvmnode
nvmnode.com › guide › download.html
Download NVM For Windows, Linux, and macOS - NVM Documentation
How to download NVM (Node Version Manager) for Windows, Linux, and macOS. Download Version Node.js related to NVM.
🌐
OpenReplay
blog.openreplay.com › switch-nodejs-versions-macos-nvm
How to Switch Node.js Versions on macOS using NVM (Step-by-Step Guide)
March 27, 2025 - You’ll likely need different Node versions if you’re a developer working on multiple projects. Node Version Manager (NVM) simplifies this. This guide will clearly explain how to install NVM, manage multiple Node versions, and troubleshoot common issues on macOS.
🌐
Medium
medium.com › marc-opolo-digital-intelligence › switch-to-node-version-manager-nvm-on-macos-using-homebrew-2c4f42034e40
Switch to Node Version Manager (nvm) on macOS using Homebrew | by Ryan Klarhölter | Marc O’Polo Digital Intelligence | Medium
February 1, 2022 - The first thing that bothered me at the start: no package manager! The obvious choice was to use Homebrew. Since choosing it, I now install everything I can with Homebrew (and that includes not only command-line tools, but even applications that come with a GUI, like Visual Studio Code or a browser, which is possible thanks to Homebrew Cask). I have also installed Node with Homebrew. When I needed a second Node version on my machine, I installed it with Homebrew (brew install node@<version>).
🌐
GitHub
github.com › nvm-sh › nvm
GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
Starred by 90.3K users
Forked by 9.7K users
Languages   Shell 98.0% | Makefile 1.2%
🌐
HeyNode
heynode.com › tutorial › install-nodejs-locally-nvm
Install Node.js Locally with Node Version Manager (nvm) | HeyNode
Install and manage a local installation of node using nvm. ... NVM stands for Node.js Version Manager. The nvm command is a POSIX-compliant bash script that makes it easier to manage multiple Node.js versions on a single environment.
🌐
Linode
linode.com › docs › guides › how-to-install-use-node-version-manager-nvm
How to Install and Use NVM (Node Version Manager) | Linode Docs
November 29, 2023 - The Node Version Manager (NVM) is an open source version manager for Node.js (Node). NVM is easy to understand and works on any POSIX-compliant shell (e.g. sh or bash). NVM allows you to easily install and manage different versions of Node and ...
🌐
SitePoint
sitepoint.com › blog › javascript › installing multiple versions of node.js using nvm
Installing Multiple Versions of Node.js Using nvm — SitePoint
March 3, 2025 - As the name suggests, it helps you manage and switch between different Node versions with ease. It provides a command-line interface where you can install different versions with a single command, set a default, switch between them and much more. nvm supports both Linux and macOS, but that’s not to say that Windows users have to miss out.
🌐
GitHub
github.com › Schniz › fnm
GitHub - Schniz/fnm: 🚀 Fast and simple Node.js version manager, built in Rust
🚀 Fast and simple Node.js version manager, built in Rust · 🌎 Cross-platform support (macOS, Windows, Linux)
Starred by 22.9K users
Forked by 594 users
Languages   Rust 66.5% | TypeScript 20.7% | JavaScript 8.2% | Shell 4.5% | Batchfile 0.1%
🌐
Volta
volta.sh
Volta - The Hassle-Free JavaScript Tool Manager
No matter the package manager, Node runtime, or OS, one command is all you need: volta install.
🌐
Node.js
nodejs.org › en › download
Node.js — Download Node.js®
InfoWant new features sooner? Get the latest Node.js version instead and try the latest improvements!
🌐
Visual Studio Code
code.visualstudio.com › docs › nodejs › nodejs-tutorial
Node.js tutorial in Visual Studio Code
November 3, 2021 - You'll need to open a new terminal (command prompt) for the node and npm command-line tools to be on your PATH. To test that you have Node.js installed correctly on your computer, open a new terminal and type node --version and you should see ...
🌐
npm
docs.npmjs.com › downloading-and-installing-node-js-and-npm
Downloading and installing Node.js and npm | npm Docs
August 18, 2025 - If you are unable to use a Node version manager, you can use a Node installer to install both Node.js and npm on your system. ... If you use Linux, we recommend that you use a NodeSource installer. If you're using macOS or Windows, use one of the installers from the Node.js download page.