Skip to content
Latchkey

Corepack "this project is configured to use yarn" in CI - Fix Package Manager Mismatch

Corepack pins a package manager via the packageManager field. When you run a different manager than the one declared, Corepack refuses and tells you which one the project expects.

What this error means

A CI step running npm or pnpm errors saying this project is configured to use yarn (or a specific version), because packageManager in package.json pins a different tool than the command invoked.

yarn
Usage Error: This project is configured to use yarn because
package.json#packageManager is set to "yarn@4.1.0".
Run "corepack enable" to make the command work.

Common causes

The job runs a manager other than the pinned one

packageManager pins yarn (or pnpm), but the CI step calls npm, so Corepack blocks it.

Corepack is not enabled in CI

Without corepack enable, the pinned manager shim is not on PATH and the command fails.

How to fix it

Enable Corepack and use the pinned manager

  1. Run corepack enable so the pinned shims are available.
  2. Invoke the manager named in packageManager.
Terminal
corepack enable
yarn install --immutable

Change packageManager if the project really uses npm

  1. Update or remove the packageManager field to match your actual tool.
  2. Commit the change so CI and local agree.

How to prevent it

  • Pick one package manager, pin it in packageManager, run corepack enable in CI, and use that same manager in every script so commands never get blocked.

Related guides

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