Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I upgrade yarn to a specific version

Tags:

yarnpkg

The Yarn documentation tells us how to upgrade to the latest version, but does not explain how to upgrade to a specific non-latest version.

I need a specific version to match our CI server.

How do I specify the version that I want?

like image 688
Taryn East Avatar asked Aug 17 '18 00:08

Taryn East


People also ask

How do I update my yarn version?

In order to update your version of Yarn, you can run one of the following commands: npm install --global yarn - if you’ve installed Yarn via npm (recommended) otherwise, check the docs of the installer you’ve used to install Yarn

What is the difference between yarn upgrade--pattern and upgrade--latest?

yarn upgrade --pattern <pattern> will upgrade all packages that match the pattern. The upgrade --latest command upgrades packages the same as the upgrade command, but ignores the version range specified in package.json . Instead, the version specified by the latest tag will be used (potentially upgrading the packages across major versions).

How do I download a specific version of yarn from GitHub?

Use a release from the local filesystem : Download the version used to invoke the command : This command will download a specific release of Yarn directly from the Yarn GitHub repository, will store it inside your project, and will change the yarnPath settings from your project .yarnrc.yml file to point to the new file.

How do I install a package in yarn?

Running `yarn add` installs it into your project. Tags are a way of publishing versions of your package with a label. Users of your package can install that instead of a version number. Packages in Yarn follow Semantic Versioning, also known as “semver”. When you install a new package it will be added with a semver version range.


2 Answers

run yarn policies set-version <version> from the project directory

https://classic.yarnpkg.com/en/docs/cli/policies/#toc-policies-set-version

like image 105
tumelo Avatar answered Sep 23 '22 07:09

tumelo


As you can see in the documentation, you can provide a version to the curl-install command with the --version flag.

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

In case you are using brew:

brew switch yarn [version]

Or maybe you installed it with npm as global package, then update like that:

npm install --global yarn@[version]

like image 43
Stefan Avatar answered Sep 23 '22 07:09

Stefan