Resolving the "zsh: command not found: yarn" Error on macOS
Giwa Jossy
Posted on June 6, 2024
As a new Mac user transitioning from a Windows environment, you will encounter some initial challenges while setting up your development environment. One of the primary issues I faced was running the yarn
command in the terminal. Here's a step-by-step account of resolving the zsh: command not found: yarn
error.
š Problem: zsh: command not found: yarn
After cloning my project repository and navigating into the directory, I tried running yarn to install dependencies but got the error below:
zsh: command not found: yarn
š Solution
This error indicates that yarn is not installed on your system. To fix this, I used Homebrew, a package manager for macOS, to install yarn.
1) Install Homebrew (if not already installed):
Homebrew simplifies the installation of software on macOS. Open your terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2) Install yarn:
With Homebrew installed, you can now install yarn by running:
brew install yarn
3) Verify yarn installation:
After the installation, verify that Yyrn is installed by running:
yarn -v
š Problem: env: node: No such file or directory
While verifying yarn installation, I encountered another error:
env: node: No such file or directory
This error indicates that yarn is installed, but it cannot find Node.js. Yarn depends on Node.js to run.
š Solution:
To resolve this, you need to install Node.js using Homebrew:
1) Install Node.js:
brew install node
2) Verify both yarn and Node.js Installation as shown below.
node -v
yarn -v
This time, the command should work without any issues, and you can proceed with installing dependencies and running your application.
Hope this helps.
Posted on June 6, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.