Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yarn is not recognized as a command on git bash in windows

I installed yarn using npm: npm i -g yarn

when I execute the command yarn -v or any other yarn command on cmd or PowerShell it Outputs the Version

But on GitBash it displays: C:\Users\<my_username>\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

I even tried Reinstalling Node & Yarn but it still doesn't work.

1 solution I found is that instead of yarn if I use yarn.cmd then it works in GitBash.

But I'm unable to find the reason & the correct solution for this problem. If someone has any Idea please Guide me.

like image 719
Shivangam Soni Avatar asked Sep 02 '25 10:09

Shivangam Soni


1 Answers

I tried so many things and in the end I'm not sure which really worked. Maybe you find out that another step works in your case.

So here's some of the sensible things I did:

  1. I reinstalled node, yarn and git because that's the default behavior of a man in confusion. (Didn't work)
  2. Tried manipulating PATH although yarn was recognized from cmd and powershell. (Didn't work)
  3. I found this: https://yarnpkg.com/getting-started/install. It seems like they updated the installation steps. So I tried that because it was something different from the yarn installation you and I used... It worked!

Now, if the last step was the one that worked, make sure to run npm uninstall -g yarn after

like image 165
Devkey Avatar answered Sep 04 '25 01:09

Devkey