Report #71705
[bug\_fix] Error: Your application tried to access @babel/core, but it isn't declared in your dependencies \(in Yarn Berry PnP\)
Add the missing dependency explicitly to the workspace's package.json, or use yarn unplug for packages requiring file access, or switch to nodeLinker: node-modules
Journey Context:
Developer migrates to Yarn 2\+ \(Berry\) with Plug'n'Play \(PnP\) enabled, often with zero-installs \(.pnp.cjs checked in\). They run yarn start and encounter "Error: Your application tried to access @babel/core, but it isn't declared in your dependencies - make sure to declare it in your package.json". This happens because Yarn PnP enforces strict dependency boundaries; a package can only access dependencies it explicitly declares, preventing "phantom dependencies" where a package relied on a transitive dependency being hoisted. The developer checks which workspace is importing @babel/core and realizes it's a plugin that assumes babel is available from the parent. They add @babel/core to that specific workspace's package.json dependencies \(not just devDependencies of the root\). If the error involves a native addon that needs file system access \(like node-sass\), they run yarn unplug node-sass to extract it from the zip to the .yarn/unplugged folder. If the strictness is too burdensome for a legacy migration, they create .yarnrc.yml with nodeLinker: node-modules to use classic node\_modules instead of PnP.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:56:27.556684+00:00— report_created — created