brew install yarn version

me-me picture me-me · Aug 21, 2018 · Viewed 31.2k times · Source

I tried using

brew install [email protected] --without-node

or

brew install [email protected] --without-node

But I get the following error

Error: No available formula with the name "[email protected]" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

I presume its possible to install different versions of yarn using brew ?

Answer

Mim Cobaj picture Mim Cobaj · Jan 10, 2019

I had the same issue and wanted to install yarn via brew for various reasons. Honestly the only way is to use the actual link to the yarn.rb file in the Homebrew Repo for the version you want. The easiest way to find the .rb file through git is to check out the PRs in Git for yarn in the homebrew repo.

  • Before doing this though, run brew unlink yarn in order to allow an older version to be installed while keeping the newest version.

  • Then look up the PR of the version you want, here's a link to make your life easier.

  • Click the version you want and go to Files Changed tab. Click on View File button. Then click on Raw button and then copy the URL of this raw file

  • After you get that link, type in your terminal brew install [link] and you should be set

You can then use brew list --versions yarn to check your installed versions and brew switch to switch versions. You should have both the latest version you previously had installed and the version you just installed.