Skip to content

'yarn' is not recognized as an internal or external command, operable program or batch file. #2504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rhtpandeyIN opened this issue Jan 19, 2017 · 43 comments

Comments

@rhtpandeyIN
Copy link

rhtpandeyIN commented Jan 19, 2017

nodejs version: 7.4.0
OS: Windows 7

I installed yarn by using yarn.msi file, and it installed successfully. But when I tried to check yarn version on my system I got following error:
'yarn' is not recognized as an internal or external command,
operable program or batch file.

At first glance I thought it may issue of incorrect PATH or may be PATH is not set by msi. Then I checked my system PATH and I found correct PATH is already there.

Solution: the problem was one extra "\" was missing after bin.
before : C:\Program Files (x86)\Yarn\bin (Not working)
After : C:\Program Files (x86)\Yarn\bin\ (Working)

Please look into the issue. Thanks.

@lubojanski
Copy link

lubojanski commented Jan 20, 2017

nodejs version: 6.5.0 and 7.4.0

Got the same problem,
now the default path was: C:\Program Files (x86)\Yarn.bin
Tried without dot and with/without slash, didn't work.

edit:
installed it by npm install yarn -g

@yfain
Copy link

yfain commented Feb 17, 2017

I don't use Windows, but if you install yarn locally, you should run its local version:
./node_modules/.bin/yarn

@rhtpandeyIN
Copy link
Author

rhtpandeyIN commented Feb 17, 2017

@yfain , I installed yarn through .msi (windows installer) file, and as per my understanding it should install globally by that, because it (yarn installation directory path) also got registered into the system path automatically. Hence it should recognize as an external command. Although when I changed path like above mentioned way, it got worked.

@locorocorolling
Copy link

Same issue as @rhtpandeyIN on windows 7 with node 6.9.1, fixed with same solution

@OutsourcedGuru
Copy link

Same issue as @rhtpandeyIN on Windows 7 Professional with node v6.9.5. Opened new command shell hoping that path would have been added—it wasn't. Manually added path to each invocation and it seems to work. I would expect an MSI to update the global path for a Windows install.

@jameswilson281
Copy link

Same issue as @rhtpandeyIN on Windows 8.1 with node v7.7.1

@fjoshuajr
Copy link

Same issue as @rhtpandeyIN on Windows 7 Ultimate x64 with node v6.9.5. Solved with the same solution.

@trondstroemme
Copy link

trondstroemme commented Apr 22, 2017

Same issue as @rhtpandeyIN on Win 10 Pro 64-bit. Resolved as per @lubojanski 's last comment.

@1j01
Copy link

1j01 commented Apr 27, 2017

Is it possible the solution of adding a backslash is working (for some people) merely by triggering some sort of update? (That the installer isn't, for some reason?) I see a lot of entries in PATH that leave off the backslash including git, nvm, nodejs, and Windows system paths. Does it still work if you change it back?

(#1648 is an older, if somewhat less descriptive issue for this problem.)

@ctcoulter
Copy link

ctcoulter commented May 29, 2017

posted this on the other read.. if anyone else is running into this issue, might help:

I was bashing my head against this one for a while. Hopefully this helps someone out.

The problem I had was that the installer placed the Yarn files in two locations that were both in my path. > The wrong one was being picked up when trying to execute.

C:\Program Files\nodejs\yarn.cmd
C:\Program Files (x86)\Yarn\bin\yarn.cmd

I just moved the files out of my nodejs directory and it worked. The error message about the path not > being found is most likely due to the %~dp0 from the nodejs directory not being in the right location.

EDIT: to add to this, just went and compared the two that were generated.. the one generated in the nodejs directory had:

@"%~dp0\..\..\Users\chris\AppData\Local\Yarn\config\global\node_modules\.bin\yarn.cmd" %*

The "node_modules" does not exist in my Yarn\config\global directory.

The yarn.cmd generated in the Yarn directory had the following (which does exist):

node "%~dp0\yarn.js" %*

I made sure that there weren't any yarn.cmd files on my hard drive at all before reinstalling via the MSI, so they were both definitely generated by the MSI installation. It might just be some kind of path configuration on my machine that caused it to generate two... but hopefully that's helpful.

@Daniel15
Copy link
Member

Daniel15 commented May 29, 2017

Hmmm... This is very strange... The trailing backslash shouldn't matter, and the current MSI has worked fine on various VMs I've tested it on, as well as on my Windows build server (which is running Windows Server 2012).

Is it possible the solution of adding a backslash is working (for some people) merely by triggering some sort of update? (That the installer isn't, for some reason?)

@1j01 This is a pretty interesting theory! We're using WiX to build the installer, and a looooot of apps use it (Node.js uses it as well, for example). I wonder if we're hitting some bug in WiX.

@rodrigoBerlochi
Copy link

I see also the same issue after installing Yarn v0.24.6
Node v6.9.0
'yarn' is not recognized as internal or external command :(
I used the msi installer for Windows.

@Daniel15
Copy link
Member

Daniel15 commented Jul 4, 2017

@rodrigoBerlochi Can you please check your path and ensure c:\Program Files (x86)\Yarn\bin was added to it?

@TrevorScrews
Copy link

I'm getting this error when trying to run yarn in powershell. The path that was added is to my AppData folder. I changed it to the c:\Program Files (x86)\Yarn\bin and still got this error. When running from the command line, it works. I didn't try from command line until the path was changed, so I'm not sure if it would have worked with the other path or not.

Node: 6.8.0
Yarn: 0.27.5

@rodrigoBerlochi
Copy link

Hi @Daniel15 Yes, it was. That was the weird point. We tried installing it using NPM. And then it worked. But I've read it isn't the recommended approach.
Thanks for your answer

@chhonmeily
Copy link

chhonmeily commented Jul 29, 2017

For window 10 user please follow these article:

  1. https://yarnpkg.com/en/docs/install#windows-tab
  2. https://yarnpkg.com/en/docs/install#alternatives-tab
    finally got it working. god damn me.

@arcanis
Copy link
Member

arcanis commented Aug 7, 2017

When your PATH is modified, the currently opened cmd windows aren't affected, you need to close them and reopen them. Could that be your issue?

@BYK
Copy link
Member

BYK commented Aug 16, 2017

Anyone sees anything we can do on the Yarn side for this or can we close the issue?

@duycoder
Copy link

I have the same problem when i install yarn the 1st time, but then i restart my windows 7 computer. It's worked. I use chocolately and run the cmd : "choco install yarn --version ...". Don't know about the other OS

@BYK
Copy link
Member

BYK commented Aug 18, 2017

@duycoder see @arcanis' answer right above: #2504 (comment)

@BYK
Copy link
Member

BYK commented Aug 18, 2017

Closing due to inability to act on this ticket.

@BYK BYK closed this as completed Aug 18, 2017
@JanisKroja
Copy link

@Daniel15 had the right solution for me, changing PATH from "C:\Users\Johnny\AppData\Local\Yarn\bin" to "C:\Program Files (x86)\Yarn\bin" fixed it.

@porkopek
Copy link

porkopek commented Sep 5, 2017

Like @arcanis said, closing cmd window and opening again, and yarn seems to be installed properly

@vantisDev
Copy link

vantisDev commented Jan 5, 2018

Just installed yarn thrugh installer. I have windows 8 x64. I had the path correctly pointing to "C:\Program Files (x86)\Yarn\bin" and had closed and reopened my cmder, and still having the issue.

I moved the Yarn folder to Program Files, modifying path accordingly. Problem solved.

I suggest you give us options depending on whether we run x32 or x64.

@kalpeshbadgujar3
Copy link

Please try by restarting IDE after installing yarn using .msi.
This might solve your problem.
Success!

@hassannomani
Copy link

Closing cmd and reopening solved the issue. Thanks @arcanis

@cuse
Copy link

cuse commented Mar 4, 2018

You can try this and it solved the problem to me.

npm install yarn -g

Thanks

@mkasina
Copy link

mkasina commented Mar 5, 2018

This worked like a charm for me..

npm install yarn -g

Thanks @cuse

@ShrutiAkkala
Copy link

Thanks, @cuse.Yes, It worked for me as well with 👍
npm install yarn -g

@ghost
Copy link

ghost commented Apr 16, 2018

There might be 2 locations of yarn, either in the AppData folder or in Program Files x86

If you've installed via chocolatey or msi, it's in the Program Files x86

Change the environment path variable to that location

@ptumuluri8
Copy link

I installed yarn using chocolatey but not globally (didn't mention -g) yarn was installed but not found in cmd. After setting the path C:\Program Files (x86)\Yarn\bin\yarn.cmd it started working.

Thanks for the group.

@snarun
Copy link

snarun commented Jun 8, 2018

Thank you! Setting the path in environment variable as well as yarn global installation solves both the problems.

@PriyankaVrma
Copy link

yarn test

Can you please help me with the solution for this one

@jd6503
Copy link

jd6503 commented Jun 18, 2018

For windows follow the below step

  • Installed yarn by using yarn.msi file.

  • Check correct the environment variable path.

    C:\Program Files (x86)\Yarn\bin\

  • Run command npm install yarn -g

@ghost
Copy link

ghost commented Aug 16, 2018

it work!

C:\Users\you>npm install yarn -g
C:\Users\you\AppData\Roaming\npm\yarn -> C:\Users\you\AppData\Roaming\npm\node
_modules\yarn\bin\yarn.js
C:\Users\you\AppData\Roaming\npm\yarnpkg -> C:\Users\you\AppData\Roaming\npm\n
ode_modules\yarn\bin\yarn.js

C:\Users\you>yarn -v
1.9.4

@yakupad
Copy link

yakupad commented Sep 7, 2018

I try Windows PowerShell

Worked for me :)

@lgloredana
Copy link

I've got the same issue today after installing yarn via msi.
For me the solution was to open a new console, yarn --version worked.
I've tried yarn --version an a console already opened before installing and it didn't worked.

@Chirag5528
Copy link

Install it in Program Files (x86) only. This solves the problem.
But raises a question why only in this folder why not in "Program Files"
Is "yarn" only applicable for 32-bit operating systems? Don't know just saying.

@tcope25
Copy link

tcope25 commented Feb 10, 2019

Restart PowerShell and it should work

@waleedshkt
Copy link

For all experiencing the issue of Windows Command Prompt not recognizing yarn, the reason behind this error being windows unable to detect PATH to the yarn's executable file.

To solve this, simply edit a PATH key under system Environment Variables and add a new path pointing to yarn. For me it's:

C:\Users\YourUserAccountName\AppData\Roaming\npm\node_modules\yarn\bin

If you go to the above path, you'll find a single file called yarn. This is what gets executed when you call yarn from your Windows Command Prompt.

And that's it! I hope it solves the aforementioned problem all of you are currently experiencing 😃

@CelticParser
Copy link

Please try by restarting IDE after installing yarn using .msi.
This might solve your problem.
Success!

This worked for vsCode

@Daniel15
Copy link
Member

Install it in Program Files (x86) only. This solves the problem.
But raises a question why only in this folder why not in "Program Files"-
Is "yarn" only applicable for 32-bit operating systems? Don't know just saying.

@Chirag5528 - It's just how the installer is built. To install into C:\Program Files, we'd need to have two separate installers: One for 32-bit, and one for 64-bit. That's a bit of a hassle. Having one single installer is more convenient, but it means the installer runs in 32-bit mode.

Yarn itself is written with Node.js and thus it is platform-insensitive.

@Daniel15
Copy link
Member

I'm going to lock this since a lot of unrelated conversations are happening here. If you have any new issues, please create a new issue. Thanks!

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Mar 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests