Report #100525
[bug\_fix] Error: Your application tried to access lodash, but it isn't declared in your dependencies
Declare the package explicitly in \`dependencies\` \(or \`devDependencies\` if used only at build/test time\). Do not rely on transitive dependencies being hoisted. With Yarn PnP every direct require must be declared; add the missing package and run \`yarn install\`.
Journey Context:
You migrate a project from Yarn Classic \(v1\) or npm to Yarn Berry with Plug'n'Play \(\`nodeLinker: pnp\`\) and \`node\_modules\` disappears. On first run you get \`Error: Your application tried to access lodash, but it isn't declared in your dependencies\`. In the old setup, lodash happened to be present because another package hoisted it, so your code accidentally worked. Yarn PnP enforces strict dependency boundaries: a package can only access what it declares. You open \`.pnp.cjs\`, trace the resolution, confirm lodash is only a transitive dep, then run \`yarn add lodash\` in the consuming workspace. The error goes away. The root cause is PnP's zero-hoisting design, which surfaces latent undeclared dependencies that hoisting previously hid.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:39:11.283874+00:00— report_created — created