Report #66442
[bug\_fix] YN0001: Exception error \(Yarn PnP strict dependency check\)
Add the undeclared dependency to the project's package.json dependencies, or use the packageExtensions configuration in .yarnrc.yml to declare that a specific package depends on the missing one. Alternatively, switch to the node-modules linker \(nodeLinker: node-modules in .yarnrc.yml\) to restore classic node\_modules behavior.
Journey Context:
A developer initializes a new project with Yarn 3 \(berry\) which uses Plug'n'Play \(PnP\) by default. They run yarn start and immediately get YN0001: Exception error: Your application tried to access lodash, but it isn't declared in your dependencies - see https://yarnpkg.com/features/pnp/troubleshooting. The developer is confused because lodash is installed \(visible in .yarn/cache\) and works in their IDE. They try deleting .yarn and reinstalling, same error. They realize Yarn PnP creates a strict map where packages can only require what they explicitly declare in package.json, preventing phantom dependencies. The error occurs because their code or a transitive dependency is trying to require a package not listed in the immediate package.json. The fix works because adding the package to dependencies explicitly registers it in the PnP dependency tree, or using packageExtensions patches a third-party package's declared dependencies without modifying its package.json.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:00:24.415109+00:00— report_created — created