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?
I found issue 1491 might contain my answer. I learned that:
%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.
Install Yarn on Windows Server via the MSI Installer First, you need to download the Yarn install package. Download the Yarn . msi installer from the official Yarn website.
Node Version Manager, more commonly called nvm, is the most popular way to install multiple versions of Node. js, but is only available for Mac/Linux and not supported on Windows.
Homebrew. You can install Yarn through the Homebrew package manager. This will also install Node.js if it is not already installed.
It's a while ago you asked, but I just stepped over your question.
You can simply install yarn as node module globally:
npm i -g yarn
This works very nicely when using nvm-windows.
Additional hint: Since switching to a new node version with nvm requires to re-install all globally installed node modules, I started to use yarn
instead of npm
for managing all other global modules except of npm and yarn itself. This way, updating node is quite painless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With