Yarn was working for me until I decided I needed multiple versions of node. So I uninstalled yarn and installed nvm, following instructions from the following guide
I then successfully re-installed yarn using the msi installer. Unfortunately, yarn global add [name]
installed packages in a location seemingly spanning all nvm-controlled node versions, 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).
So I uninstalled the yarn msi. I then re-installed yarn simply with npm i --global yarn
, as suggested here. This, at last, caused yarn to be linked to the current nvm controlled node version. Excellent.
However, when I again tried yarn to install global packages I discovered they were not installed properly. For example I ran:
nvm use 5.11.0
yarn global add jspm gulp karma karma-cli
The packages installed successfully, but when I try "gulp" from the command line, it is not available. Also, when I npm ls --global --depth=1
I see that the packages I installed are nowhere to be found. If I try yarn global ls --depth=0
it takes a very long time to tell me that my packages (jspm, gulp, karma, karma-cli) are in fact installed.
Worse, I later decided to do the following:
nvm use 7.3.0 //fresh node install...no packages installed
npm i --global yarn
yarn global ls
The yarn command then shows me the same packages that I installed globally when nvm use 5.11.0
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 "clean" of an uninstall I could attempt.
In short, I don't think yarn and nvm are compatible. Is this correct?
Version Info
- Windows 10 Pro, x64
- nvm v1.1.3
- yarn v0.21.3
- node 5.11.0 (selected by NVM)
- node 7.8.0 (selected by NVM)
Update
I found issue 1491 might contain my answer. I learned that:
- The location of yarn packages installed globally is intentionally in a different location than packages installed globally for npm.
- 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.
- The location where Yarn keeps its data on Windows is
%LocalAppData%\Yarn
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 npm i --global yarn
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.