Report #12226
[bug\_fix] Error: Cannot find module 'ms' \(or any package\) even though it is in node\_modules/.pnpm/...
Add the missing package explicitly to the project's package.json dependencies \(do not rely on hoisting\), or configure .npmrc with public-hoist-pattern\[\]=package-name to selectively hoist specific packages, or use --shamefully-hoist \(not recommended\) to flatten node\_modules like npm.
Journey Context:
Developer switches from npm to pnpm for faster installs, runs pnpm install which completes successfully, starts application and it crashes at runtime with "Cannot find module 'debug'", investigates and finds that 'debug' was a transitive dependency of express that their code was importing directly \(phantom dependency\), npm had hoisted it to root and accessible by all packages even if not declared, but pnpm's strict isolation prevents this, identifies the package that needs 'debug' but doesn't declare it, either adds it to that package's deps or uses pnpmfile to patch it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:21:38.365997+00:00— report_created — created