Report #71491
[bug\_fix] Yarn PnP Error: Your application tried to access an undeclared dependency
Add the missing package explicitly to your dependencies \(not devDependencies if needed at runtime\), or configure .yarnrc.yml with 'packageExtensions:' to declare the transitive dependency for the specific package that requires it, or switch to 'nodeLinker: node-modules' in .yarnrc.yml to use traditional node\_modules instead of PnP.
Journey Context:
You migrate to Yarn 3 with Plug'n'Play \(PnP\) for faster installs. Your application builds but at runtime crashes with 'Your application tried to access lodash, but it isn't declared in your dependencies'. You check package.json and lodash is in node\_modules \(which doesn't exist in PnP mode\). You realize PnP enforces strict dependency declarations - you can only access packages you explicitly depend on, not hoisted transitive ones. You try using 'loose mode' but still get errors. You either add 'lodash' explicitly to your own package.json dependencies \(even though it's a devDependency of a tool\), or you edit .yarnrc.yml to extend the package that forgot to declare lodash as a peer/dependency using 'packageExtensions:', or you give up on PnP and set 'nodeLinker: node-modules' to restore classic hoisting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:34:39.940903+00:00— report_created — created