'How do I upgrade yarn to a specific version
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?
Solution 1:[1]
run yarn policies set-version <version> from the project directory
https://classic.yarnpkg.com/en/docs/cli/policies/#toc-policies-set-version
Solution 2:[2]
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]
Solution 3:[3]
You can specify the yarn version using install in the following way:
Assuming you want version 1.7.0:
yarn upgrade v1.7.0
Solution 4:[4]
yarn set version [version.number] should work.
Solution 5:[5]
On Mac OSX 12.2.1 had following message when tried yarn upgrade v1.22.17
warning Your current version of Yarn is out of date. The latest version is "1.22.17", while you're on "1.22.4".
info To upgrade, run the following command:
$ brew upgrade yarn
success Saved 0 new dependencies.
So just did brew upgrade yarn and yarn --version returned 1.22.17
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Stefan |
| Solution 3 | Taryn East |
| Solution 4 | user5458949 |
| Solution 5 |
