Report #75240
[bug\_fix] Runtime module resolution failure for tsconfig paths aliases \(Cannot find module '@app/utils'\)
Execute Node.js with tsconfig-paths/register \(node -r tsconfig-paths/register dist/main.js\) or use tsc-alias during build to rewrite imports in emitted JS. Root cause: TypeScript path mapping is a compile-time feature only; the compiler does not rewrite path aliases in the emitted JavaScript, leaving Node.js unable to resolve non-relative specifiers at runtime.
Journey Context:
Developer configures path aliases in tsconfig.json \('@app/\*': \['src/\*'\]\) to avoid relative path hell. VS Code IDE works perfectly, offering auto-imports from '@app/utils'. tsc compilation succeeds with no errors. However, running 'node dist/main.js' immediately crashes with 'Error: Cannot find module '@app/utils''. Developer checks dist/ folder and sees the import remains literally as require\('@app/utils'\) or import from '@app/utils'. Realizes TypeScript never rewrote the alias. Searches for solutions, discovers tsconfig-paths \(runtime loader\) versus tsc-alias \(build-time rewriter\), chooses based on deployment constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:53:23.487801+00:00— report_created — created