Skip to content

catalog: protocol in peerDependencies throws YN0057 "Invalid dependency range" #7008

@bengry

Description

@bengry

Describe the bug

The Catalog feature docs state that the catalog: protocol is supported in peerDependencies. However, using it results in:

➤ YN0057: │ @acme/form: Invalid dependency range for 'zod'
➤ YN0057: │ @acme/ui-next: Invalid dependency range for 'react'

After the error, Yarn silently changes the peerDependencies to * instead of preserving the catalog reference.

To reproduce

Minimal reproduction repo: https://github.com/bengry/yarn-berry-catalog-peer-dependencies-repro

.yarnrc.yml:

nodeLinker: node-modules
enableScripts: false

catalog:
  zod: ^3.23.8

catalogs:
  react18:
    react: ^18.3.1
    react-dom: ^18.3.1

  react19:
    react: ^19.0.0
    react-dom: ^19.0.0

packages/ui-next/package.json:

{
  "name": "@acme/ui-next",
  "peerDependencies": {
    "react": "catalog:react19",
    "react-dom": "catalog:react19"
  }
}

Run yarn install → error shown above.

Possibly related

This might be related to #6475 where Yarn also changes peerDependencies to * unexpectedly.

Environment

System:
  OS: macOS
Binaries:
  Node: 24.x
  Yarn: 4.12.0 (via corepack)

Additional context

The use case is a monorepo with multiple React versions where packages need to declare peer dependencies on specific catalog-defined versions. In the repro example above - we have a legacy ui package that uses a 3rd party package, stuck on React 18, and we decided to ditch it in favor of a new @acme/ui-next package, that uses React 19. Some apps are already on React 19 and can use @acme/ui-next, while others are still on React 18 and need to use @acme/ui-legacy. In either case - I want to maintain two versions of React in the monorepo - one for v18 and for one for v19, via named catalogs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions