Report #76721
[bug\_fix] Cannot find module '@scope/package' in monorepo workspace
Use nohoist configuration for the specific package, or ensure the workspace dependency is built before the consumer, or switch to pnpm workspaces which handle hoisting correctly via content-addressable store.
Journey Context:
Developer works in a Yarn/Lerna monorepo where package A depends on package B in the same workspace. After running install, Node throws "Cannot find module '@myorg/package-b'" when A tries to require it. Checking node\_modules reveals package B was hoisted to root but A has a nested node\_modules with a conflicting version, or B's symlink is missing because it wasn't built \(TypeScript source not compiled to dist\). Developer consults Yarn workspaces documentation and adds nohoist: \["\*\*/package-b"\] to root package.json to prevent incorrect hoisting, or ensures the build step runs for workspace dependencies before consumption. In pnpm, this is avoided due to strict node\_modules structure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:22:01.553166+00:00— report_created — created