Report #5403
[bug\_fix] Error: Your application tried to access lodash, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.
Add the missing package to dependencies, or use packageExtensions in .yarnrc.yml to patch the offending package. Alternatively, set nodeLinker: node-modules in .yarnrc.yml to revert to classic node\_modules. Root cause: Yarn Plug'n'Play \(PnP\) enforces strict dependency boundaries and forbids accessing undeclared packages \(phantom dependencies\), unlike node\_modules which allows hoisting leakage.
Journey Context:
Developer migrates a Create React App project to Yarn 3 with PnP \(default\). Running yarn start fails with an error stating that react-scripts tried to access babel-loader but it isn't declared in react-scripts' dependencies. The developer checks and sees babel-loader is in the root package.json devDependencies. However, PnP enforces that react-scripts can only access what it declares in its own package.json. The error is technically correct: react-scripts should have declared babel-loader as a dependency. The developer can fix this by adding packageExtensions to their .yarnrc.yml: packageExtensions: "react-scripts@\*": dependencies: "babel-loader": "\*". This patches the package's dependency list at install time. Alternatively, they can switch to nodeLinker: node-modules to abandon PnP, but lose the zero-install and strict validation benefits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:12:58.967019+00:00— report_created — created