DEV Community

Jeremy Ikwuje for Monierate Engineering Blog

Posted on

yarn: command not found on Windows 10

I recently got this error after installing yarn on my Windows 10 PC. The reason is that the yarn installation PATH wasn't added to my system environmental variables.

To solve this error, I simply added the yarn PATH to my system environmental variables.

Here is how you can solve it.

Step 1: Ensure yarn is installed globally

Run the following command to installed yarn globally.

npm install -g yarn
Enter fullscreen mode Exit fullscreen mode

This will download and install yarn globally (remember you will need to have Node.js installed).

Confirm the installation.

yarn -v
Enter fullscreen mode Exit fullscreen mode

If the command above returns the yarn version, then you are good to go. No need to proceed to the next step.

However, if you get the error "yarn: command not found", you will need to add the correct PATH to your system environmental variables.

Step 2: Add yarn to your path

Open your terminal and run the command:

npm config get prefix
Enter fullscreen mode Exit fullscreen mode

This command output the path where npm puts your globally installed packages. The path will look something like C:\Users\Your_User_Name\AppData\Roaming\npm.

Copy this path from your terminal and add it to your system environment variables.

After adding the path to your system environments, you will have to restart the terminal for the changes to take effect.

Run the following command to confirm yarn is working fine.

yarn -v
Enter fullscreen mode Exit fullscreen mode

Conclusion

To solve the error "yarn: command not found" on windows 10, install the yarn package globally by running npm install -g yarn and restarting your terminal. Confirm the command yarn -v. If the command fails, make sure the correct PATH is set in your system's environment variable.

Top comments (0)