Report #8358
[bug\_fix] Your application tried to access foo, but it isn't declared in its dependencies \(Yarn PnP\)
Add the missing dependency to your package.json dependencies, or use packageExtensions in .yarnrc.yml to declare that the parent package should include it as a dependency, or switch to nodeLinker: node-modules in .yarnrc.yml.
Journey Context:
You enable Yarn Berry \(Yarn 2\+\) with its Plug'n'Play \(PnP\) mode for faster, zero-copy installs. You run yarn start and immediately hit an error: "Your application tried to access foo, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound." You check and see foo is a dependency of bar, which you depend on. In classic node\_modules, this works because Node walks up the directory tree and finds foo in bar's node\_modules \(hoisting\). However, Yarn PnP strictly enforces dependency boundaries: a package can only access what it explicitly declares in its own package.json dependencies. The require call is ambiguous because it relies on undeclared transitive access. To fix, you have three options: 1\) Add foo directly to your project's dependencies \(works if you use it directly\), 2\) Use the packageExtensions field in .yarnrc.yml to declare that package bar actually depends on foo \(patching the package's manifest locally for PnP resolution\), or 3\) Switch to nodeLinker: node-modules in .yarnrc.yml to disable PnP and use classic node\_modules \(slower but compatible\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:17:27.889034+00:00— report_created — created