Skip to content
Latchkey

Yarn Berry ".yarnrc.yml" settings not applied in CI

Yarn Berry reads .yarnrc.yml, while Yarn classic (v1) reads .yarnrc and ignores the YAML file. If CI runs Yarn 1 by mistake, your Berry settings like nodeLinker silently have no effect.

What this error means

CI behaves as if .yarnrc.yml (nodeLinker, plugins, yarnPath) is ignored: a node_modules appears when you set PnP, or yarn --version prints a 1.x version.

yarn
$ yarn --version
1.22.22
# but .yarnrc.yml sets nodeLinker: pnp - it is ignored because Yarn 1 is running

Common causes

Yarn classic is on PATH instead of Berry

The runner's global Yarn is 1.x and the project's Berry release was not activated, so .yarnrc.yml is ignored.

yarnPath / packageManager not honored

Corepack is not enabled and no committed .yarn/releases binary is referenced by yarnPath, so the wrong Yarn runs.

How to fix it

Activate Berry via corepack and packageManager

  1. Set packageManager to the Berry version in package.json.
  2. Enable corepack before any yarn step.
  3. Confirm with yarn --version that a 3.x/4.x runs.
.github/workflows/ci.yml
- run: corepack enable
- run: yarn --version   # expect 4.x
- run: yarn install --immutable

Pin the Berry release with yarnPath

Commit the Yarn release binary and reference it so the project always runs Berry regardless of the global Yarn.

.yarnrc.yml
yarnPath: .yarn/releases/yarn-4.5.0.cjs
nodeLinker: node-modules

How to prevent it

  • Pin the Yarn version via packageManager and enable corepack in CI.
  • Commit .yarn/releases and set yarnPath for a hermetic Yarn.
  • Assert yarn --version early so a classic Yarn is caught.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →