Report #7304
[bug\_fix] Error: Your application tried access lodash but it isn't declared in your dependencies \(Yarn PnP\)
Run the script through Yarn's Node wrapper \(yarn node server.js instead of node server.js\) to inject the PnP runtime, or add the missing package to dependencies if it's actually required but undeclared. Root cause: Yarn PnP \(Plug'n'Play\) does not create node\_modules; it uses a .pnp.cjs file to map imports. Running node directly does not load this map, so require\(\) cannot find packages even if they are installed.
Journey Context:
You migrate to Yarn 3 and run yarn install. You notice no node\_modules folder exists \(expected with PnP\). You try to run your app with node server.js and immediately get 'MODULE\_NOT\_FOUND' for express, despite it being in package.json. You check .yarnrc.yml and see nodeLinker is not set to node-modules. You realize PnP requires the Node process to be started via Yarn to inject the resolver. You change your command to yarn node server.js. The .pnp.cjs runtime is now loaded, require\('express'\) resolves through Yarn's virtual map, and the server starts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:19:23.602413+00:00— report_created — created