Why does corepack try to install yarn v1.22 by default when v4.11 is the latest?

103 views Asked by At

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?

1

There are 1 answers

0
M455 On BEST ANSWER

If the packageManger 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:

  • Set the packageManger field in your project's package.json to your preferred version (e.g. "packageManger": "[email protected]"), then run yarn to install the dependencies using that package manager version.
  • Update Corepack's Known Good Release for yarn with corepack up -g [email protected].

Links