Report #10140
[bug\_fix] Cannot find module with pnpm \(phantom dependencies\)
Add the missing package explicitly to the project's package.json dependencies or devDependencies using \`pnpm add \`. Do not rely on transitive dependencies being hoisted to the root. Root cause is pnpm's strict node\_modules isolation where packages can only access dependencies they explicitly declare; accessing a dependency that happens to be present due to hoisting in npm/yarn \(phantom dependency\) is blocked.
Journey Context:
A developer switches a large React project from npm to pnpm to save disk space. After running \`pnpm install\`, they start the dev server and immediately encounter \`Error: Cannot find module 'tslib'\` despite the application working fine with npm. They inspect node\_modules and notice the physical file structure is different due to pnpm's content-addressable store and strict symlinking. They realize that one of their dependencies is importing 'tslib' but doesn't list it in its own package.json. With npm, 'tslib' was hoisted to the root by chance. With pnpm's strict isolation, this phantom dependency is blocked. They explicitly add 'tslib' to their project's dependencies with \`pnpm add tslib\`, and the application starts successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:53:12.971787+00:00— report_created — created