If you recently installed nvm - Node Version Manager package using brew and when you run the nvm command you get - zsh: command not found: nvm on your macOS system. Well, the reason is you have not set the zsh profile file to locate the installed nvm package.
Let's see what we see when we install nvm using the command: brew install nvm
code2care@mac ~ % brew install nvm
==> Downloading https://github.com/creationix/nvm/archive/v0.38.0.tar.gz
Already downloaded: /Users/code2care/Library/Caches/Homebrew/downloads/1956ad942b9ae30bf5f0d9ccb61b90c5ae466dc790b470b5f766eed629b43947--nvm-0.38.0.tar.gz
==> Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.
You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm
Add the following to ~/.zshrc or your desired shell
configuration file:
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh"
# This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && .
"/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
# This loads nvm bash_completion
You can set $NVM_DIR to any location, but leaving it unchanged from
/opt/homebrew/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.
Type `nvm help` for further information.
==> Summary
🍺 /opt/homebrew/Cellar/nvm/0.38.0: 7 files, 176KB, built in 1 second
As you can see in the installation logs, you need to update the .zshrc file with the NVM details after you create .nvm file under ~/ location.
How to fix nvm not found error:
- Execute command: mkdir ~/.nvm
- Run command: brew --prefix nvm to know the installation location.
code2care@mac ~ % brew --prefix nvm /opt/homebrew/opt/nvm
- Open zsh profile file: nano ~/.zshrc
- Add the below line to the file:
export NVM_DIR="$HOME/.nvm" . "/opt/homebrew/opt/nvm/nvm.sh"
- Save the changes: Control + X followed by Y Key.
- Update changes: source ~/.zshrc
- Now try to run nvm commands: example: nvm list
![nvm command not found zsh - brew installation nvm command not found zsh - brew installation](https://code2care.org/q/zsh-command-not-found-nvm-brew-macos/images/nvm command not found zsh - brew installation.png)
Install nvm using package manager
If you are making use of the zsh shell on other platforms, then you can try the below table to look for the appropriate command to install nvm package using the default command package manager.
Operating System | Package Manager | Command to Install nvm |
---|---|---|
macOS | Homebrew | brew install nvm or curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh |
Linux (Debian/Ubuntu) | apt-get | sudo apt-get install curl && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh |
Linux (CentOS/RHEL) | yum | sudo yum install curl && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh |
Windows | - | nvm-windows (download and run from official git repo https://github.com/coreybutler/nvm-windows) |
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Fix: grunt: command not found (Mac/Windows)
- AppleScript Example with TextEdit
- How to copy Password of Wifi on your Mac
- Install OpenJDK Java (8/11/17) versions using brew on Mac (Intel/M1/M2)
- How to check if a port is in use using terminal [Linux or macOS]
- Cut, Copy and Paste Keyboard Shortcuts on Mac Keyboard
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required.
- How to Remove Widgets from macOS Sonoma 14 Desktop
- Turn off Auto-Capitalization on macOS Ventura 13
- How to Go To /usr/local/bin on Mac Terminal?
- How to Open TextEdit on Mac
- Mac: How to Open Android Studio from Terminal
- How to change the default location of Mac Screenshot
- Display Seconds in Digital Clock on Mac Menu Bar [macOS]
- How to install homebrew (brew) on M1 Mac
- Must Know Homebrew Commands for Mac/Linux Users
- Steps to Uninstall Roblox on Mac (macOS)
- How to change the System Settings Sidebar icon size Mac Ventura 13
- How to set Out Of Office (OOO) on Outlook for Mac [Updated 2023]
- Trigger Notification Center Message using Mac Terminal Command
- [fix] macOS Ventura - Python3 xcrun: error: invalid active developer path missing xcrun at CommandLineTools
- How to Install Rust Language on Mac (macOS)
- How to minimize all Windows in Mac
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- How to make TextEdit the default text Editor on Mac
- Steps to Uninstall Roblox on Mac (macOS) - MacOS
- The Python3 command requires the command line developer tools. Would you like to install the tools now? - Python
- Docker Commit Command with Examples - Docker
- Install the minimal Linux on Docker (only 5 mb Alpine Linux) - Docker
- How to Compare Strings in Bash - Bash
- Convert Instant timestamp into LocalDateTime Java Code Example - Java
- Spring Boot Web + Thymeleaf Hello World Example in IntelliJ in 5 Easy Steps - Java
- How to add to PATH in macOS Big Sur - MacOS