If you encounter the “zsh: command not found: yarn” error when trying to use the Yarn package manager in your Zsh shell on macOS, it’s likely that Yarn isn’t installed properly or its executable path isn’t included in your system’s PATH variable.
Here’s how you can fix this issue:
- Check Yarn Installation: First, verify if Yarn is installed on your system. Open a terminal window and type the following command:
If Yarn is installed, it should display the version number. If not, you’ll need to install Yarn using a package manager like Homebrew.
- Install Yarn using Homebrew: If Yarn is not installed, you can install it using Homebrew. Homebrew is a popular package manager for macOS. Open your terminal and run the following commands:
brew install yarn
- Update your Zsh configuration: After installing Yarn, you might need to update your Zsh configuration to include Yarn’s executable path in the PATH variable. Edit your Zsh configuration file (usually
~/.zshrc) using a text editor of your choice, such as
Add the following line to your
export PATH="$PATH:`yarn global bin`"
Save and close the file, then refresh your shell by running:
- Verify Yarn Installation: To ensure Yarn is now accessible, type:
It should display the Yarn version without any errors.
- Restart Terminal or Shell: If you still encounter the “zsh: command not found: yarn” error, try restarting your terminal or shell to ensure that the changes take effect.
Following these steps should help you resolve the “zsh: command not found: yarn” error on your Mac when using the Zsh shell. Remember to follow each step carefully, and your Yarn installation should work as expected.