Report #93264
[gotcha] ESM module resolution resolves symlinks to realpath \(unlike CJS\), breaking monorepo relative imports
Use \`createRequire\` for CJS-style resolution, or avoid relative imports across symlink boundaries; use workspace protocols instead of relative paths in monorepos.
Journey Context:
In CJS, \`require\` resolves module specifiers lexically against the symlink location, so a package accessed via a symlink in \`node\_modules\` can use \`../\` to reach sibling packages. In ESM, the specifier is resolved against the realpath of the importing module. This means \`../\` from a symlinked package resolves to the source directory \(\`packages/foo/..\`\), not \`node\_modules/..\`, breaking relative imports in pnpm/Yarn workspaces. The only robust fixes are to use Node's \`createRequire\` to get CJS resolution in ESM files, or to eliminate relative cross-package imports in favor of workspace alias protocols \(\`workspace:\*\`\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:07:54.040915+00:00— report_created — created