Resolving the "zsh: command not found: yarn" Error on macOS

giwajossy

Giwa Jossy

Posted on June 6, 2024

Resolving the "zsh: command not found: yarn" Error on macOS

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
Enter fullscreen mode Exit fullscreen mode

šŸ˜Š 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)"
Enter fullscreen mode Exit fullscreen mode

2) Install yarn:
With Homebrew installed, you can now install yarn by running:

brew install yarn
Enter fullscreen mode Exit fullscreen mode

3) Verify yarn installation:
After the installation, verify that Yyrn is installed by running:

yarn -v
Enter fullscreen mode Exit fullscreen mode

šŸ˜‘ Problem: env: node: No such file or directory
While verifying yarn installation, I encountered another error:

env: node: No such file or directory
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

2) Verify both yarn and Node.js Installation as shown below.

node -v
yarn -v
Enter fullscreen mode Exit fullscreen mode

This time, the command should work without any issues, and you can proceed with installing dependencies and running your application.

Hope this helps.

šŸ’– šŸ’Ŗ šŸ™… šŸš©
giwajossy
Giwa Jossy

Posted on June 6, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related