yarn
yarn copied to clipboard
Installer does not set PATH correctly on windows
After installing yarn on my machine i noticed that the command was not found because the content was installed on C:\Program Files (x86)\Yarn\bin, but PATH was set to be under User AppData folder, manually setting the environment variable fixed the issue.
OS: Windows 10 (1511 build 10586.164) Node: v6.5.0
Did you install with chocolatey or normal MSI installer?
Sorry i forgot to mention that i installed it with MSI
Strange... It should definitely be adding c:\Program Files (x86)\Yarn\bin
to the path, see here: https://github.com/yarnpkg/yarn/blob/master/resources/winsetup/Yarn.wxs#L30-L38
Note that c:\Program Files (x86)\Yarn\bin
is added to the system path, while the AppData path is added to the user path. The AppData path is for modules you install globally through Yarn, while the system path is for Yarn itself.
What exactly is the purpose of the user/appdata yarn path?
It's supposed to be for packages you install globally (eg. yarn global install foo
), I think there's some bugs at the moment and it's placing those modules in the wrong directory. Yarn should still work without it.
I had the same problem, on my laptop there was no problem, but for my desktop at work I had to add an extra backslash to the end of the path, so \bin\
instead of \bin
@jcbvm's fix worked for me as well.
Installation with the MSI (downloaded today) installed to C:\Program Files (x86)\Yarn\bin\
, but the PATH variable was updated to \AppData\Local\Yarn\.bin
. I may be more confused by the extra period in \.bin
.
changing PATH variable to C:\Program Files (x86)\Yarn\bin\
(noting extra \
at the end) solved the problem.
I tried installing with chocolately and with the .msi and had the same problem in both cases. The PATH environment variable was updated to
C:\Users\{username}\AppData\Local\Yarn\.bin
in both cases. Yarn was not installed there. The install log indicated that Yarn was actually installed at C:\Program Files (x86)\Yarn.
Updating my PATH environment variable to
C:\Program Files (x86)\Yarn\bin
solved that problem for me.
@dev6rodn - There's two parts to the path - The system path, and the user path. C:\Program Files (x86)\Yarn\bin
is added to the system path by the installer, so it should already be there.
I installed Yarn via Chocolatey. My bash shell was initially unable find Yarn, but a restart of my PC fixed the path issue. (Probably a log out, then log back in would have been enough.)
I am also seeing the exact same issue as @dev6rodn is reporting. The same solution worked for me.
Straight after installing from the msi
, it was not working for me either! Then I realized my CMD / Terminal was opened before the installation. I restarted the terminal and it worked!
yarn -v
Edit - on windows 10 I had to restart windows. on windows 7 it worked Ok.
This what I got on windows 10 after using the msi
@zivni Tnx! A restart works for me on window 10
For me on windows 10, I had the following:
User PATH variable: ...;C:\Users\canders2\AppData\Local\Yarn\.bin;...
System PATH variable: ...;C:\Program Files (x86)\Yarn\bin;...
I fixed by simply appending \
at the end of the System PATH variable (...;C:\Program Files (x86)\Yarn\bin\;...
).
@claycephas thanks man! It works under Windows 7 too, here.
On Windows 10, I see both PATH
env vars (system and user) were updated, but opening a fresh command prompt, it doesn't seem to be pulling in the updated PATH. echo %PATH%
doesn't show yarn
anywhere. Adding a backslash didn't help.
Is it possible the solutions of adding a backslash or replacing the AppData\Local\Yarn\.bin
entry with the Program Files (x86)\Yarn\bin
entry are working merely by triggering some sort of update? (That the installer isn't?)
@1j01 - The AppData directory is only for global packages you install via Yarn (using yarn global add
). Yarn itself should be in c:\Program Files (x86)\Yarn\bin\
. Is the Program Files directory not on your system PATH
?
@Daniel15 I know. Yeah, it's in there, it's just not being pulled in.
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.
Took me a bit to realize I had been using Yarn on a new Windows machine without problems. It's because I installed with npm without even really thinking about it.
npm install yarn -g
Is the installer like a gimmick that's suppose to let us forget about npm? You should just install with npm. You have NodeJS to use the installer anyway, so you definitely have npm.
FYI - you don't need to have NPM for Yarn to work. I don't install npm, and opt to install Yarn by itself.
You have NodeJS to use the installer anyway, so you definitely have npm.
No, you don't. Many people on Windows use the Node.js executable directly, which doesn't include npm: https://nodejs.org/dist/v6.11.2/win-x64/node.exe. You can just throw this executable into a directory on your path (I use c:\apps
for miscellaneous executables) aud run it. Additionally, minimal Node.js installations on other systems might not include npm. This is particularly the case on production servers - Why would you need npm on a prod server?
Is the installer like a gimmick that's suppose to let us forget about npm?
The idea is that Yarn is not specific to Node.js. Someone that has no clue about Node.js or npm should still be able to use Yarn.
Okay thank you for the clarification then. I have only installed the whole environment.
@ptpaterson I'll try re-installing via npm then.
So much for RTFM!
Why would the Yarn Installation (linked to from the npm yarn page) NOT mention
npm install yarn -g
as an option ?
Instead, it states that we must first install Chocolatey or Scoop, and then use that to install yarn !
What a cluster!
Neither choco
nor yarn
is found, outside my C:/Users/username
directory.
Meanwhile, Chocolatey decided to globally update node to version 8.
Yep! - under the guise of running the required chocolateyInstall.ps1
script, the choco installation instead globally updated my node
to version 8.4.0
(LTSR is at 6.x.x)!, then asked again for permission to install that ps1
script, which it did.
Since node 8 is set for LTSR in october, it's probably ok for any code that I'm actively working on.
Still, this became unnecessarily messy.
Thanks to everyone for your helpful advice!
@SherylHohman hey, sorry for all the trouble and the late response! I agree urging people to install other stuff just to get yarn
installed is not ideal. I think the assumption there is that people already have these on their system, which is not the case sometimes.
We do not encourage installing with npm install yarn -g
since both yarn
and npm
are package managers and more importantly, other installation mechanisms have signature verification such as GPG which is not available on npm
. We think a package manager is critical enough to verify publisher signatures.
Anyway, what would be the most convenient method for you so we can update the docs for others?
You can download the Windows installer and use that if you don't have Chocolatey or Scoop installed.
Sent from my phone.
On Sep 5, 2017 2:39 AM, "Burak Yiğit Kaya" [email protected] wrote:
@SherylHohman https://github.com/sherylhohman hey, sorry for all the trouble and the late response! I agree urging people to install other stuff just to get yarn installed is not ideal. I think the assumption there is that people already have these on their system, which is not the case sometimes.
We do not encourage installing with npm install yarn -g since both yarn and npm are package managers and more importantly, other installation mechanisms have signature verification such as GPG which is not available on npm. We think a package manager is critical enough to verify publisher signatures.
Anyway, what would be the most convenient method for you so we can update the docs for others?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yarnpkg/yarn/issues/1648#issuecomment-327125095, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFnHR2AjRueCMrVajWo5O5_L8j4E2KMks5sfRbGgaJpZM4KoTkD .
To add to your Powershell $profile
(assuming you have PSCX):
Add-PathVariable "${env:ProgramFiles(x86)}\Yarn\bin"
Would be nice for the install page to clarify either:
- That npm can be used to install yarn (and how)
- That npm should not be used to install yarn (and why)
FWIW, I experienced this issue today after installing Yarn using the Windows .msi.
The installer added C:\Program Files (x86)\Yarn\bin
to PATH
user variable and C:\Program Files (x86)\Yarn\bin\
to Path
system variable.
After installation finished, I closed an open instance of Git Bash (no other command prompts open, at least not visibly) and then tried yarn --version
. This resulted in "command not found" in Git Bash and "not recognized as an internal or external command" in Windows command line. I closed the command prompts and opened them again to try the command a few more times with the same results. Finally, I removed the backslash from the end of the system variable and then it worked. However, I then added the backlash back and it still works.
Perhaps there was a background process that was preventing the updated system variable from being usable?
Can confirm that this problem still exists with the windows-build-1.6.0