Report #53203
[bug\_fix] Error: tried to access , but it isn't declared in its dependencies \(Yarn PnP\)
Add the missing dependency to the consuming package's dependencies or peerDependencies if you control it, OR use the packageExtensions configuration in .yarnrc.yml to virtually declare the undeclared dependency for that specific package version without modifying the package itself.
Journey Context:
Developer migrates from Yarn 1 \(Classic\) to Yarn 2\+ \(Berry\) with Plug'n'Play \(PnP\) enabled. Running yarn start immediately throws errors like 'react-scripts tried to access @babel/plugin-syntax-flow, but it isn't declared in its dependencies'. The app worked fine in Yarn 1. The developer realizes Yarn PnP enforces strict dependency boundaries - a package can only access dependencies explicitly listed in its own package.json. In node\_modules \(Yarn 1/npm\), undeclared dependencies were accessible via hoisting \(ghost dependencies\). The fix involves using packageExtensions in .yarnrc.yml to tell Yarn: 'treat react-scripts as if it has @babel/plugin-syntax-flow in its dependencies'. This patches the package manifest virtually without requiring node\_modules or forking the package.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:47:51.848066+00:00— report_created — created