Report #21556
[bug\_fix] Yarn PnP Error: Your application tried to access \[package\], but it isn't declared in your dependencies
Unplug the package with yarn unplug, configure packageExtensions in .yarnrc.yml to declare missing peer dependencies, or switch to nodeLinker: node-modules in .yarnrc.yml.
Journey Context:
You migrate to Yarn 3 with Plug'n'Play enabled \(default\). Running the app throws 'Error: Your application tried to access lodash, but it isn't declared in your dependencies'. Checking node\_modules, you find it's empty \(PnP uses .pnp.cjs\). The error means a package is importing lodash without listing it as a dependency, relying on hoisting. PnP enforces strict dependency boundaries. You check which package is at fault using yarn why lodash. If it's a missing peer dependency, you add to .yarnrc.yml: packageExtensions: 'package-name@\*': peerDependencies: lodash: '\*'. If the package needs unzipping for patching, you run yarn unplug package-name. This declares the missing relationship in the PnP map, allowing resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:35:48.116370+00:00— report_created — created