Report #83752
[bug\_fix] pnpm: Cannot find module 'lodash' \(phantom dependency\) or ENOTEMPTY
Add shamefully-hoist=true to .npmrc or use --shamefully-hoist flag. Root cause: pnpm uses a strict isolated node\_modules with symlinks to a virtual store, preventing access to undeclared transitive dependencies \(phantom deps\) that legacy tools expect.
Journey Context:
You migrate to pnpm for disk space savings. pnpm install works, but running the app throws 'Cannot find module lodash' even though it's a transitive dep of another package. You inspect node\_modules and see lodash is not at the root, only in the virtual store \(.pnpm\). Your webpack config or a legacy tool is trying to require a phantom dependency. You try adding the missing packages to your package.json manually, but there are dozens. Finally, you add shamefully-hoist=true to .npmrc, wipe node\_modules and lockfile, reinstall, and pnpm now hoists all dependencies to the root like npm, satisfying the legacy requires.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T23:09:50.948932+00:00— report_created — created