Report #36163
[bug\_fix] Cannot find module '@app/utils' or its corresponding type declarations
Install and configure tsconfig-paths \(or tsc-alias\) to rewrite path mappings at runtime/build, or migrate to Node.js native subpath imports via package.json "imports" field. Root cause: TypeScript path mapping is compile-time only for type resolution; the compiler does not rewrite '@app/\*' to relative paths in emitted JavaScript.
Journey Context:
Developer configures path aliases in tsconfig.json \(e.g., "@app/\*": \["./src/\*"\]\) to avoid relative path hell. VS Code IntelliSense works perfectly, and tsc compiles without errors. However, running node dist/index.js immediately crashes with "Cannot find module '@app/utils'". Checking the emitted dist/ files reveals the import statement remains literally require\("@app/utils"\). The developer initially suspects a build cache issue, then discovers TypeScript's design philosophy: paths are purely for type-checking, not emit rewriting. After searching, they find the tsconfig-paths package \(or tsc-alias\) which provides a runtime hook or post-build rewrite to translate these aliases to relative paths that Node.js can resolve.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:10:22.448630+00:00— report_created — created