Report #11641
[bug\_fix] Error: Your application tried to access \[package\], but it isn't declared in your dependencies \(Yarn PnP\)
Add the missing package to the specific package's dependencies \(not just root\), or use 'packageExtensions' in .yarnrc.yml to patch upstream packages that forgot to declare deps, or switch to 'nodeLinker: node-modules' in .yarnrc.yml to disable PnP strictness.
Journey Context:
You migrate to Yarn 3 with Plug'n'Play for zero-installs. Running 'yarn start' crashes with 'Your application tried to access lodash, but it isn't declared in your dependencies'. The stack trace points to 'webpack-dev-server' trying to require lodash. In classic node\_modules, this worked because of hoisting. In PnP, strict dependency boundaries are enforced. You check 'webpack-dev-server's package.json and see lodash is indeed missing from its dependencies \(a bug in that version\). You use 'yarn dlx @yarnpkg/doctor' to find undeclared dependencies. You add a 'packageExtension' in .yarnrc.yml to inject lodash into webpack-dev-server's dependencies. Yarn reinstalls, PnP map updates, and the application starts because PnP can now trace the explicit dependency edge.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:49:57.748728+00:00— report_created — created