Report #7473
[bug\_fix] Error: Your application tried to access rxjs, but it isn't declared in your dependencies - YARN\_PNP\_ERROR
Run yarn unplug \[package-name\] to extract the package to .yarn/unplugged for compatibility with native addons or tools requiring file system access, or add the missing dependency to package.json if it was a phantom dependency.
Journey Context:
Developer adopts Yarn 3 with its default Plug'n'Play \(PnP\) mode. Clones a repository and runs yarn install. Then runs yarn start. The application crashes with an error stating it tried to access a package that isn't declared in dependencies. Developer checks package.json and sees the package is indeed listed. Confused, they learn that Yarn PnP uses a .pnp.cjs file to map imports and strictly enforces that packages can only access their explicitly declared dependencies \(no phantom deps\). If the package is a native addon with postinstall scripts or if it tries to dynamically require a peer, PnP might block it. The developer runs yarn unplug lodash which extracts the package to .yarn/unplugged, allowing it to work with PnP. If the issue is a missing peer declaration, they use packageExtensions in .yarnrc.yml to patch the dependency's package.json locally.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:47:01.619159+00:00— report_created — created