Report #100998
[bug\_fix] TS2307: Cannot find module '@/utils/auth' or its corresponding type declarations.
Keep the tsconfig.json paths/baseUrl mapping for the compiler, but register a runtime resolver such as \`tsconfig-paths/register\` \(e.g., \`node -r tsconfig-paths/register dist/index.js\` or in ts-node/jest setup\) so Node.js can resolve the alias at execution time. Alternatively convert the alias to a Node.js subpath import \(\`\#utils/auth\`\) with \`imports\` in package.json, which is resolved by Node natively.
Journey Context:
The project had a \`paths\` alias in tsconfig.json pointing \`@/\*\` to \`src/\*\`, and \`tsc --noEmit\` passed cleanly. But running the compiled output with \`node dist/main.js\` immediately crashed with TS2307/Cannot find module. I first suspected the build was not copying files, then tried \`tsc-alias\` and \`typescript-transform-paths\`. After checking the emitted JS, I noticed the import string was still \`@/utils/auth\`; TypeScript never rewrites paths. The realisation was that \`paths\` is only a type-checking/compiler-time convenience, not a runtime module resolver. Adding \`tsconfig-paths/register\` made Node follow the same map at runtime, so the alias resolved to the correct relative path under \`dist/\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:48:41.950216+00:00— report_created — created