Background
Root package.json pins packageManager: yarn@4.9.1, but three child workspaces pin an older version:
| Workspace |
packageManager |
| root |
yarn@4.9.1 |
application/backend |
yarn@4.0.2 |
application/common |
yarn@4.0.2 |
application/integrations |
yarn@4.0.2 |
(application/user-client and application/admin-client don't declare packageManager.)
Running make seed from a fresh clone triggers a Corepack prompt to download the older 4.0.2:
yarn prisma:migrate
! Corepack is about to download https://repo.yarnpkg.com/4.0.2/packages/yarnpkg-cli/bin/yarn.js
? Do you want to continue? [Y/n]
This happens because make seed runs yarn prisma:migrate, which enters the backend workspace's context. Corepack sees the backend's own packageManager declaration and downloads that specific version, even though yarn install at root already used 4.9.1.
Not sure if the divergence is intentional (some behaviour depended on 4.0.2 specifically) or leftover from an incomplete upgrade after the root was bumped to 4.9.1.
Problem
Functionally, nothing breaks. Both Yarn versions run scripts correctly. Two smaller issues:
- Mid-setup Corepack prompt. New contributors get a "download this other Yarn version" prompt right after
yarn install at root already downloaded 4.9.1. Reads as accidental.
- Two Yarn versions cached per developer. Each machine ends up with both
4.9.1 and 4.0.2 in Corepack's cache.
In a Yarn workspaces monorepo, child workspaces usually shouldn't declare packageManager at all. One declaration at root governs the whole tree cleanly, and per-workspace fields are redundant and drift-prone.
Proposed approach
Two options, either works:
Removing the field from children is arguably cleaner because it removes the possibility of future drift.
Background
Root
package.jsonpinspackageManager: yarn@4.9.1, but three child workspaces pin an older version:packageManageryarn@4.9.1application/backendyarn@4.0.2application/commonyarn@4.0.2application/integrationsyarn@4.0.2(
application/user-clientandapplication/admin-clientdon't declarepackageManager.)Running
make seedfrom a fresh clone triggers a Corepack prompt to download the older 4.0.2:This happens because
make seedrunsyarn prisma:migrate, which enters the backend workspace's context. Corepack sees the backend's ownpackageManagerdeclaration and downloads that specific version, even thoughyarn installat root already used 4.9.1.Not sure if the divergence is intentional (some behaviour depended on
4.0.2specifically) or leftover from an incomplete upgrade after the root was bumped to4.9.1.Problem
Functionally, nothing breaks. Both Yarn versions run scripts correctly. Two smaller issues:
yarn installat root already downloaded 4.9.1. Reads as accidental.4.9.1and4.0.2in Corepack's cache.In a Yarn workspaces monorepo, child workspaces usually shouldn't declare
packageManagerat all. One declaration at root governs the whole tree cleanly, and per-workspace fields are redundant and drift-prone.Proposed approach
Two options, either works:
packageManagerfield entirely fromapplication/backend,application/common, andapplication/integrations. Root's declaration then governs all workspaces.Removing the field from children is arguably cleaner because it removes the possibility of future drift.