Report #8157
[bug\_fix] Error: Your application tried to access X, but it isn't declared in your dependencies \(Yarn PnP\)
Switch nodeLinker to node-modules in .yarnrc.yml or unplug the package. Root cause: Yarn 2\+ PnP \(Plug'n'Play\) enforces strict dependency boundaries and doesn't use node\_modules; packages must explicitly declare all dependencies they access.
Journey Context:
Migrated to Yarn 3 for zero-installs. Enabled Plug'n'Play by default. Ran the app and got 'Your application tried to lodash, but it isn't declared in your dependencies'. Realized a file was importing lodash but package.json didn't list it \(it was working before because it was hoisted from a sub-dependency\). Tried using 'yarn unplug lodash' which exposed it to the filesystem but still required declaring it. Eventually set 'nodeLinker: node-modules' in .yarnrc.yml to restore the classic node\_modules resolution while keeping Yarn's other features, as PnP strictness required refactoring all implicit dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:45:22.784092+00:00— report_created — created