23

I'm on Windows 7, and I tried to install typescript with yarn:

yarn global add typescript

success Installed typescript@2.0.6 with binaries:
  - tsc
  - tsserver
Done in 11.59s.

After successful installation, I type tsc in the command line, only to find that the command is not available.

yarn tsc
yarn tsc v0.16.1
error Command "tsc" not found.

Get config:

yarn config get prefix
C:\Program Files (x86)\Nodist\bin

I checked this path: there's no tsc or tsserver exectuables. Where is it?

Aurora0001
  • 13,139
  • 5
  • 50
  • 53
Nick
  • 8,451
  • 13
  • 57
  • 106
  • Possible duplicate of [Yarn global installs to current directory](http://stackoverflow.com/questions/40330759/yarn-global-installs-to-current-directory) – rofrol Nov 16 '16 at 10:54
  • See this issue: https://github.com/yarnpkg/yarn/issues/1226 – Junle Li Nov 21 '16 at 04:09
  • Were you running `tsc` or `yarn tsc`? I would have expected you would run the former, not the latter. – Aurora0001 Nov 23 '16 at 15:13
  • @JunleLi Thanks. Glad to hear that this is fixed by the official yarn team. It seems that yarn won't play well with nodist on Windows. – Nick Nov 24 '16 at 06:51
  • Thank you for pointing it out. Actually, I tried both. Maybe Linux/Mac would saved me a lot of trouble. But I am just learn programming as a hobby, could not left Windows for daily office use. – Nick Nov 24 '16 at 06:54
  • On Windows, it is `%LocalAppData%\Yarn\bin` – Manohar Reddy Poreddy Sep 17 '22 at 13:57

2 Answers2

24

Answering the actual question and using the default directory, rather than changing it:

Yarn installs to ${env:LOCALAPPDATA}\yarn\bin

You can see this with:

yarn global bin

For example, after installing gulp:

$ ls ${env:LOCALAPPDATA}\yarn\bin


    Directory: C:\Users\mike\AppData\Local\yarn\bin


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        13-Aug-18   4:11 PM            348 gulp
-a----        13-Aug-18   4:11 PM             57 gulp.cmd

To ensure it's in your path, add this to your $profile (assuming you have PSCX ):

Add-PathVariable ${env:LOCALAPPDATA}\yarn\bin
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
-2

Check it with

yarn config get prefix

It works now:

mkdir ~/yarn-global
yarn config set prefix ~/yarn-global

Add ~/yarn-global to your PATH env var.

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
rofrol
  • 14,438
  • 7
  • 79
  • 77