I can see corepack about to download yarn v1.22 when I run the yarn
command:
user@laptop:~/empty-directory$ yarn
Corepack is about to download https://registry.yarnpkg.com/yarn/-/yarn-1.22.22.tgz.
Do you want to continue? [Y/n]
I'm using corepack v0.25.2.
The latest release of yarn is v4.11 at the time of writing: https://github.com/yarnpkg/berry/releases
Why is this version being downloaded, and how can I make yarn 4.1.1 the default version that Corepack uses?
If the packageManager
field in package.json is not specified, Corepack will download the global version of the package manager that Corepack is configured with (Corepack also calls these 'Known Good Releases'). To use a different version of yarn, you can either:
packageManager
field in your project's package.json to your preferred version by running yarn set version 4.1.1
, or by modifying/creating your package.json manually to have the field "packageManager": "yarn@4.1.1"
, then run yarn
to install the dependencies using that package manager version.corepack install -g yarn@4.1.1
.