Report #66682
[bug\_fix] Error: Your application tried to access lodash, but it isn't declared in your dependencies - Yarn PnP
Add the missing dependency to package.json, or run yarn unplug \[package\] for packages needing file system access, or set nodeLinker: node-modules in .yarnrc.yml to disable PnP
Journey Context:
Developer migrates to Yarn Berry and enables Plug'n'Play. Installs everything, commits .yarn/cache. Runs node index.js and gets 'Cannot find module' for a package that is in the cache. Realizes PnP requires strict dependency declarations \(no phantom dependencies\). Fixes package.json to explicitly list all imports. Tries again, now gets errors about packages needing file system access like sharp or eslint plugins. Learns that native modules or tools reading from node\_modules must be 'unplugged' via yarn unplug \[package\], which extracts them from the zip cache to a real folder. Alternatively, gives up on PnP and sets nodeLinker: node-modules in .yarnrc.yml to restore classic node\_modules behavior.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:24:31.683612+00:00— report_created — created