Report #4897
[bug\_fix] Error: Your application tried to access lodash, but it isn't declared in your dependencies
Add the missing package as a direct dependency \(yarn add lodash\), or if the access is happening inside a dependency that forgot to declare it, use packageExtensions in .yarnrc.yml to tell Yarn that the upstream package has an undeclared dependency. The root cause is Yarn PnP's strict dependency model which forbids accessing packages not explicitly listed in package.json.
Journey Context:
You upgrade to Yarn 4 with Plug'n'Play. Running yarn dev crashes with 'Your application tried to access lodash, but it isn't declared in your dependencies'. Confused because lodash is in node\_modules \(wait, there is no node\_modules\). You check .pnp.cjs and see the dependency tree. Realizing PnP enforces strict dependency declarations, you find that one of your dependencies is using lodash but didn't declare it in its package.json \(a phantom dependency\). Instead of hacking, you add a packageExtensions entry in .yarnrc.yml declaring that the faulty package depends on lodash, run yarn install to update the PnP map, and the error resolves.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:15:45.794491+00:00— report_created — created