After installing the homebrew on my macOS, when I ran the brew command on the Terminal app I received the error zsh: command not found: brew
Error:Code2care@Mac % brew install node
zsh: command not found: brew
![zsh: command not found: brew zsh: command not found: brew](https://code2care.org/zsh/fix-zsh-command-not-found-brew/images/zsh: command not found: brew.png)
Solutions to brew command is not found an error!
- Open the .zshrc file using command: nano ~/.zshrc,
- Now add the following to the file: export PATH="$PATH:/opt/homebrew/bin/"
- Save the file by pressing Control + X followed by Enter.
- Apply the changes by command: source ~/.zshrc
Solution 1:
When you install brew in macOS it gets installed at the location - /opt/homebrew, in order to run the brew command you need to cd this location and get into the bin directory and run the brew commands.
The above solution will work but is not an ideal way of running the brew command, it's better to add the path of brew installation in the .zshrc file
Solution 2:
![Editing .zshrc file for brew path Editing .zshrc file for brew path](https://code2care.org/zsh/fix-zsh-command-not-found-brew/images/Editing zshrc file for brew path.png)
Now you can run the brew command from anywhere!
![Brew command working after zshrc file update Brew command working after zshrc file update](https://code2care.org/zsh/fix-zsh-command-not-found-brew/images/Brew command working after zshrc file update.png)
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
- Resolve - zsh: command not found: code
- zsh: command not found [fix] macOS
- How to fix: zsh: command not found: jupyter
- How to make ZSH as the default shell on Ubuntu
- How to Add New Entry to ZSH PATH
- Add Syntax Highlighting in Zsh Shell
- Fix: zsh: command not found: npm after installation (Node.js)
- Fix: zsh: command not found: mysql (Mac XAMPP)
- Ubuntu zsh: command not found: nano
- Fix: ZSH: cd: too many arguments (macOS)
- Fix - cd: no such file or directory: .zshrc
- How to reload zsh shell profile file?
- Fix zsh: permission denied: script.sh
- [fix] zsh: illegal hardware instruction python TensorFlow M1/M2 Mac
- macOS Ventura 13: The default interactive shell is now zsh
- How to Add Autocomplete in Mac Terminal
- Fix - zsh: command not found: pip
- ZSH: exec format error eclipse M1/M2 Mac
- Setting up Zsh Syntax Highlighting
- How to reload Zsh .zshrc Profile
- zsh: command not found: brew [fix]
- How to clear ZSH history of commands executed on Mac Terminal
- Fix - zsh: command not found: conda [macOS]
- Fix: cd: string not in pwd
- Fix: error: mismatched closing delimiter } [Rust] - Rust
- Project JDK is not defined [IntelliJ IDEA] - Java
- How to enable root user on Mac Terminal - MacOS
- Fix Microsoft Office 365 error code 135011 - Your organization has disabled this device - Microsoft
- Get Desc of Table using Java JDBC - Java
- Show Hidden Files in Mac Terminal - MacOS
- Error when deleting SharePoint Online folder or file - SharePoint
- Share Multiple Images in WhatsApp using Android Intent - WhatsApp