me-me
me-me

Reputation: 5809

brew install yarn version

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 ?

Upvotes: 29

Views: 89195

Answers (6)

cheesydoritosandkale
cheesydoritosandkale

Reputation: 609

Some of the above answers don't seem to work anymore. Here is how I was able to install a specific version in April 2021:

brew unlink [email protected] (If you already have a version installed)

brew extract --version 1.22.4 yarn homebrew/cask

brew install [email protected]

yarn -v

Upvotes: 11

heyfranksmile
heyfranksmile

Reputation: 309

Hope this works for you guys.

To reinstall run below.

// Note:(updating homebrew) for Mac users.

brew install -g yarn

if yarn is still not found

brew reinstall yarn

Upvotes: 3

mynk
mynk

Reputation: 11

You could also use yarn policies set-version <version>, but it has a caveat; it will "check in your Yarn release within your repository. Once you run it, your configuration will be updated in such a way that anyone running a Yarn command inside the project will always use the version you set - and this transparently."

You might not want to have the Yarn release in your repository.

Official doc

Upvotes: 1

Lukas
Lukas

Reputation: 10340

You can also use yvm, a yarn version manager instead of homebrew to install a specific or multiple versions of yarn

https://yvm.js.org/docs/overview

Enables easy switching between yarn versions, like nvm does for node

Upvotes: 7

Sandeep
Sandeep

Reputation: 29

As per official github page https://github.com/yarnpkg/yarn/issues/599 you should use "brew install -g yarn" to install yarn using brew.

PS: I've installed Xcode and gcc before running above command as i ran into few issues when executed above command.

Upvotes: 1

Mim Cobaj
Mim Cobaj

Reputation: 331

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.

Upvotes: 33

Related Questions