title: Can Yarn and NVM Coexist on Windows?
body: <p>Yarn was working for me until I decided I needed multiple versions of node.  So I uninstalled yarn and installed nvm, following instructions from <a href="http://digitaldrummerj.me/windows-running-multiple-versions-of-node/" rel="noreferrer">the following guide</a></p>
  <p>I then successfully re-installed yarn using the msi installer.  Unfortunately, <code>yarn global add [name]</code> installed packages in <a href="https://github.com/creationix/nvm/issues/1280" rel="noreferrer">a location seemingly spanning all nvm-controlled node versions</a>, and yet equally inaccessible to all of them.  That is, npm could not find anything installed globally by yarn.  Or, for example, after using yarn to install gulp globally, I find that gulp is not available on the command line (and its cmd files are not found in c:\program files\nodejs).</p>
  <p>So I uninstalled the yarn msi.  I then re-installed yarn simply with <code>npm i --global yarn</code>, as <a href="https://stackoverflow.com/questions/40025890/why-wouldnt-i-use-npm-to-install-yarn">suggested here</a>.  This, at last, caused yarn to be linked to the current nvm controlled node version. Excellent.</p>
  <p>However, when I again tried yarn to install global packages I discovered they were not installed properly. For example I ran:</p>
  <pre><code>nvm use 5.11.0
  yarn global add jspm gulp karma karma-cli
  </code></pre>
  <p>The packages installed successfully, but when I try &quot;gulp&quot; from the command line, it is not available.  Also, when I <code>npm ls --global --depth=1</code> I see that the packages I installed are nowhere to be found.  If I try <code>yarn global ls --depth=0</code> it takes a very long time to tell me that my packages (jspm, gulp, karma, karma-cli) are in fact installed.</p>
  <p>Worse, I later decided to do the following:</p>
  <pre><code>nvm use 7.3.0    //fresh node install...no packages installed
  npm i --global yarn
  yarn global ls
  </code></pre>
  <p>The yarn command then shows me the same packages that I installed globally when <code>nvm use 5.11.0</code> had been in effect.  In short, yarn insists on some kind of global install location (separate from what nvm controlled node versions see).  I also do not know the file location where yarn is keeping those global packages, so I'm not sure how &quot;clean&quot; of an uninstall I could attempt.</p>
  <p>In short, I don't think yarn and nvm are compatible.  Is this correct?</p>
  <h1>Version Info</h1>
  <ul>
  <li>Windows 10 Pro, x64</li>
  <li>nvm v1.1.3</li>
  <li>yarn v0.21.3</li>
  <li>node 5.11.0 (selected by NVM)</li>
  <li>node 7.8.0 (selected by NVM)</li>
  </ul>
  <h1>Update</h1>
  <p>I found <a href="https://github.com/yarnpkg/yarn/issues/1491" rel="noreferrer">issue 1491</a> might contain my answer.  I learned that:</p>
  <ol>
  <li>The location of yarn packages installed globally is intentionally in a different location than packages installed globally for npm.</li>
  <li>There is indeed a yarn bug which prevents globally installed packages from being available on the command line (doh!).  This defeats the purpose of the global install of a package.</li>
  <li>The location where Yarn keeps its data on Windows is <code>%LocalAppData%\Yarn</code></li>
  </ol>
  <p>I think the reason yarn was working before I installed nvm, is simply that I had not tried using to install global packages...and thus had not yet noticed the bug.  In short, I think it is fine with nvm.  However, I now feel I am wasting my time using the <code>npm i --global yarn</code> approach to installing yarn...since yarn will simply put all its global packages into one spot anyway.  And, due to the current bug, the only tool I should use for installing global packages is npm itself.</p>