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?
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
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).
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.
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.
run yarn policies set-version <version>
from the project directory
https://classic.yarnpkg.com/en/docs/cli/policies/#toc-policies-set-version
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]
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