Report #13435
[bug\_fix] Cannot find module '@shared/utils' or its corresponding type declarations at runtime despite successful TypeScript compilation
Use a runtime loader that understands TypeScript path mappings \(e.g., \`tsx\` or \`ts-node\` with \`tsconfig-paths/register\`\), or rewrite the imports to relative paths during build using \`tsc-alias\`. TypeScript's \`paths\` are design-time only and do not transform emitted JS.
Journey Context:
Developer sets up a pnpm monorepo and configures \`compilerOptions.paths\` in \`tsconfig.json\` to map \`@shared/\*\` to \`./packages/shared/src/\*\`. VS Code IntelliSense works perfectly, and \`tsc --noEmit\` passes. However, running \`node dist/apps/api/index.js\` throws \`Error: Cannot find module '@shared/utils'\`. The developer inspects the \`dist/\` folder and sees \`require\("@shared/utils"\)\` remains unchanged, realizing TypeScript does not rewrite module specifiers. After searching, they find that \`paths\` is only for type resolution. They try \`ts-node\` with \`tsconfig-paths/register\` for development and \`tsc-alias\` for production builds, understanding the boundary between the type system and the Node.js module loader.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:45:39.950701+00:00— report_created — created