Report #93765
[bug\_fix] Yarn PnP Error: Your application tried to access ... but it isn't declared in your dependencies
Add the missing package to your \`package.json\` dependencies \(not devDeps if used in production\), or use \`packageExtensions\` in \`.yarnrc.yml\` to inject the dependency where it's missing, or switch to \`nodeLinker: node-modules\` in \`.yarnrc.yml\` to disable PnP.
Journey Context:
You upgrade to Yarn 2 \(Berry\) with the default Plug'n'Play \(PnP\) mode enabled. After running \`yarn install\`, you start your application and it crashes with a Yarn error stating your app tried to access \`lodash\`, but it isn't declared in your dependencies. Confused, you check and see that \`lodash\` \*is\* a dependency of one of your dependencies, so it should be available. You realize that PnP enforces strict dependency boundaries: you can only import packages explicitly declared in your own \`package.json\`. You could add \`lodash\` to your deps, but that duplicates the version management. Instead, you learn about \`packageExtensions\` in \`.yarnrc.yml\`, which allows you to patch the dependency tree to declare that \`some-library\` actually depends on \`lodash\`, satisfying PnP's constraints without modifying the library code. Alternatively, you set \`nodeLinker: node-modules\` to revert to the traditional node\_modules folder.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:58:11.552408+00:00— report_created — created