How to change the version of yarn used?

I used Homebrew to install yarn . Running yarn -v shows that I'm currently using 0.23.2 . I ran brew upgrade yarn to get the latest version 0.24.6 .

After Homebrew successfully updated yarn , I run yarn -v again, but the version is still 0.23.2 . How can I change the version of yarn that I use?

+28
source share
8 answers

I have found the answer. This is not the yarn , but since yarn always tells me which is the latest version of the update, I can use npm to just install the latest version.

If the latter is 0.24.6

 npm install --global yarn@.24.6 

EDIT:

According to the official yarn documentation, installation / upgrade method:

 brew install yarn brew upgrade yarn 

https://yarnpkg.com/en/docs/install#mac-stable

+26
source

You can use the homegrown and yarn formula URLs to set older yarn versions, and then, if necessary, brew switch between yarn versions. Works great! Thanks to github robertmorgan.

  1. First of all, if you already have a version installed, disconnect it from brew by running the brew unlink yarn in your terminal.

  2. Then, in a web browser, find the combined extraction request containing the Yarn formula (version) that you want to install.

  3. Browse the files modified in this Formula/yarn.rb Pull - there should be one for Formula/yarn.rb

  4. Click the browse button for the Formula/yarn.rb to see the entire contents of the file for this commit.

  5. Click the button to view the raw version of this file. This will open a URL that should start with https://raw.githubusercontent.com/....

    This is the URL you will need for the next step, so copy the full URL to the clipboard.

  6. Returning to the terminal window, use the brew install command and then the copied URL.

    For example, to install v1.6.0 yarn this would be:

     brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/fba7635ab69384ac980c635483a7af825bc06088/Formula/yarn.rb 

You can then check the versions available for Homebrew by running: brew list --versions yarn , and switch between versions using brew switch yarn VERSION_NUMBER

Source: https://github.com/yarnpkg/yarn/issues/1882#issuecomment-421372892

+21
source

Assuming you have a different version installed, you can run

 brew switch yarn <old_version> 

To view a list of installed versions:

 brew list --versions yarn 
+17
source

It is best to use a yarn version manager .

Installation:

curl -fsSL https://raw.githubusercontent.com/tophat/yvm/master/scripts/install.sh | bash

One-time use:

yvm exec <version> <command>

Or change the current version of the yarn

 yvm use <version> yarn --version 
+13
source

Easy to set up and switch between any number of yarn versions.

https://github.com/tophat/yvm

+8
source

Here is a way to do this with curl and bash :

 curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.24.6 # or another version 

This works whether you have yarn or not.

0
source
 yarn policies set-version <version number> 

By https://github.com/yarnpkg/yarn/issues/7146#issuecomment-477809216

0
source
 sudo apt-get remove yarn sudo apt-get install yarn=1.3.2-1 
-5
source

Source: https://habr.com/ru/post/1268689/


All Articles