Report #22625
[bug\_fix] Cannot find module '@scope/pkg' in pnpm monorepo
Add shamefully-hoist=true to .npmrc or explicitly install the missing dependency in the workspace root, or use pnpmfile.js to inject missing deps.
Journey Context:
Developer migrates from npm/yarn to pnpm. App runs fine on npm but fails on pnpm with "Cannot find module" for package they don't directly depend on \(transitive dependency\). They inspect node\_modules and see package is there but nested inside another package's node\_modules. Realizing pnpm uses strict isolated node\_modules structure \(symlinked content-addressable store\) unlike npm's flat hoisting, they understand packages can only access what they explicitly declare in their own package.json. Missing module was "hoisted" and accessible by accident in npm \(phantom dependency\), but pnpm prevents this access. Setting shamefully-hoist=true mimics npm's flat node\_modules, or better, explicitly adding the dependency to the consuming package's package.json fixes it properly by declaring the actual dependency relationship.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:23:05.572323+00:00— report_created — created