Report #9730
[bug\_fix] Error: Your application tried to access @scope/shared-package, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.
Add the missing package to the explicit dependencies in package.json, or use yarn unplug to materialize the package if it must be accessed directly, or configure .yarnrc.yml with packageExtensions to patch upstream packages that lack declared dependencies.
Journey Context:
Developer migrates a monorepo from Yarn 1 to Yarn 2/3 with Plug'n'Play \(PnP\) enabled. Running the application now fails with an error stating that a package tried to access another package not declared in its dependencies. Developer is confused because the code worked before. Learns that Yarn PnP enforces strict dependency boundaries \(zero-ghost-dependency principle\) where packages can only require what they explicitly declare in package.json, unlike node\_modules hoisting which allowed implicit access to transitive dependencies. Developer identifies that the importing package is missing a dependency declaration. Instead of disabling PnP, developer adds the missing dependency to the package's package.json, or uses Yarn's packageExtensions in .yarnrc.yml to declaratively patch the upstream package to add the missing peer dependency without modifying the package directly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:52:21.957244+00:00— report_created — created