How to Fix “yarn: command not found” Error

Are you using node.js for designing projects? When working with node.js, which is a runtime JavaScript environment, you can have the liberty to make various projects. Programmers have been using node.js for the back-end work. Yarn is the package manager for JavaScript projects. In yarn, you can use other programmers’ code or even share your snippets, projects, or components with others. It is a reliable and secure code to handle JavaScript code. When working with yarn, you may get a “yarn: command not found” Error.

You must be wondering why you are getting this error warning pops up. Let’s figure out the reason

Why the error shows up?

Two major aspects can lead to the error. If you don’t have the package installed correctly or the path of the variable is not set up, you can land in the error.

Check out the solution to fix the error

Solution To Fix “yarn: command not found” Error

We have a few short yet effective solutions to help you remove the error.

Solution 1 – Yarn installation

The main cause of the error is not having the yarn installed in your system. You just need to install Yarn to get the issue solved. Follow this command

npm install -g yarn

Once done, you need to verify if it is installed successfully, and for this, you need to use the below command

yarn –version

If the error persists, you need to use the following command

sudo npm install -g yarn

This may fix the error warning.

Solution 2 – Set NPM path into Path variable

Another effective way to resolve the error, you just need to set the NPM path into the path variable. In the case, you are not aware of the NPM path, you can find it out using the below command

npm config get prefix

with this command, you get the full path of your npm folder that is required to adjust the path variable.

## Replace Path with Your npm folder path export PATH="/usr/local/share/npm/bin:$PATH"

After this, just restart the terminal, then run the Yarn version. In this way, you may fix the error.

Solution 3 – Set Path variable

To solve the error, you need to add yarn in the path variable. For this, you need to follow the below procedure step-by-step

  • On your keyboard, press the Window button, and type Environment
  • Tap on Edit the System Environment Variables
  • Select the Environment Variables button, found on the dialogue, System Properties
  • Choose Path and tap the button Edit
  • To add a new path, tap the button New
  • Next, just Copy the Yarn path that can be found here:
  • You can also find the path with npm config get prefix
  • Copy the above path
  • Once done, just paste the global binary path you copied.
  • Click OK to save the change
  • Restart all terminals
  • Check yarn version
  • It resolves the error.


And that’s how you can fix the “yarn: command not found” Error. All the solutions are effective and helpful.

Reference Source:

Leave a Reply

Your email address will not be published. Required fields are marked *