Report #60575
[bug\_fix] Module not found: Can't resolve '@app/utils' at runtime despite successful TypeScript compilation
The TypeScript 'paths' compiler option only remaps imports for type-checking; the emitted JavaScript retains the original bare specifier. To fix, use a runtime module resolution helper like 'tsconfig-paths/register' for Node.js, use 'tsc-alias' to rewrite imports post-compilation, or switch to a bundler \(esbuild, Vite\) that handles path mapping during the build.
Journey Context:
You add a path alias '@app/utils' to tsconfig.json to clean up imports. The IDE autocompletion works perfectly, and 'tsc' runs without errors. You confidently run 'node dist/index.js' and crash immediately with 'Error: Cannot find module @app/utils'. You triple-check the paths configuration, try adding 'baseUrl', even reinstall node\_modules. You discover that tsc never rewrites import paths—it assumes your runtime environment \(Node.js\) understands the alias, which it doesn't. You descend into a rabbit hole of comparing 'moduleResolution' strategies, trying 'NodeNext' vs 'Node', before realizing you need a runtime loader or build-step rewrite.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:09:45.378741+00:00— report_created — created