Report #73566
[bug\_fix] pnpm shamefully-hoist broken package resolution
Set shamefully-hoist=true in .npmrc at the project root, or use public-hoist-pattern\[\]=\* to hoist all packages, or selectively hoist only the problematic packages using public-hoist-pattern\[\]=@babel/\*
Journey Context:
Developer switches a large React project from npm to pnpm for faster installs. After running pnpm install, the install completes but the dev server crashes with Cannot find module '@babel/core' or Cannot find module 'webpack'. Developer checks node\_modules and sees it's a symlinked structure \(content-addressable store\), not flat. They realize that some tools \(like old CRA, React Native, or certain babel plugins\) spawn child processes or use require.resolve in ways that assume dependencies are hoisted to the root node\_modules. Since pnpm is strict, these assumptions break. Developer tries adding the missing packages as direct dependencies, but the error just moves to the next missing transitive dependency. Finally, they create a .npmrc file with shamefully-hoist=true, delete node\_modules and pnpm-lock.yaml, and reinstall. The project works because pnpm now creates a flat node\_modules structure similar to npm/yarn classic. Why it works: pnpm's default strict node\_modules structure prevents phantom dependencies \(using undeclared packages\). However, some legacy tooling relies on hoisting \(where all transitive deps are flattened to root\). shamefully-hoist tells pnpm to create a flat node\_modules, sacrificing the strictness guarantees for compatibility with broken packages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:04:30.057634+00:00— report_created — created