Report #78881
[bug\_fix] Error: Your application tried to access lodash, but it isn't declared in your dependencies - see https://yarnpkg.com/advanced/rulebook\#packages-must-only-ever-require-which-they-declare
Declare the missing dependency explicitly in package.json, or if the access is from a transitive dependency with missing declarations, add a packageExtensions entry in .yarnrc.yml to patch the third-party package to declare the dependency.
Journey Context:
You enable Yarn Berry with Plug'n'Play \(PnP\) for zero-installs and stricter dependency management. Immediately on running the app, you get a stack trace saying your app tried to access 'lodash' but it isn't declared in dependencies. You check and lodash is in node\_modules \(well, .yarn/cache now\). You realize that in PnP mode, unlike node\_modules, packages cannot require dependencies they didn't explicitly declare - no implicit hoisting. You find that a transitive dependency is requiring lodash without declaring it as a dependency \(a 'ghost dependency'\). You can't modify the third-party package directly. You search Yarn docs and find packageExtensions in .yarnrc.yml allows you to inject dependency declarations into packages that are missing them. You add the extension, yarn install, and the resolution works. You commit the .yarnrc.yml as it now documents the necessary patches for the ecosystem.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:59:58.184909+00:00— report_created — created