If you are getting a "zsh: command not found: yarn" error, the yarn command is unavailable in your current shell session. This can happen if yarn is not installed on your system or if the yarn executables are not added to your shell's PATH.
To fix this error, you can try one of the following solutions:
- Check if yarn is installed on your system by running the following command:
yarn --version
If yarn is installed, this command should print the version number, e.g. 1.22.4
. If the command is not found, it means that yarn is not installed, and you will need to install it.
- If yarn is installed, but the command is not found, you will need to add the yarn executables to your shell's PATH. This will vary depending on the shell you are using. For example, in bash, you can add the following line to your
~/.bashrc
file:
export PATH="$PATH:$HOME/.yarn/bin"
Make sure to replace $HOME/.yarn/bin
with the actual path to the bin
directory where yarn executables are located. After modifying the .bashrc
file, run the following command to apply the changes:
source ~/.bashrc
Once yarn is installed and its executables are added to your PATH, you should be able to run the yarn
command without any issues.
Install YARN
To install yarn on MacOS, Linux, or Windows, you can use the following steps:
-
Download the latest version of yarn from the official website: https://yarnpkg.com/en/docs/install
-
For MacOS, double-click the
.pkg
file to open the installer, then follow the on-screen instructions to install yarn. -
For Linux, run the following command to install yarn:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
- Double-click the .msi file to open the installer for Windows, then follow the on-screen instructions to install yarn.
After yarn is installed, you can verify the installation by running the yarn --version
command, which should print the version number of yarn.