Report #17957
[bug\_fix] Cannot find module '@app/utils' or its corresponding type declarations. ts\(2307\) despite tsconfig paths being configured
Configure the runtime/bundler to resolve the paths, not just TypeScript. Install \`vite-tsconfig-paths\` for Vite, \`tsconfig-paths\` for Node, or configure Webpack \`resolve.alias\`. The root cause is that TypeScript's \`paths\` mapping is only for compile-time type resolution; it does not rewrite module specifiers in emitted JS. The runtime needs explicit configuration to map the logical path to the physical file.
Journey Context:
You set up path aliases in \`tsconfig.json\` with \`"baseUrl": "."\` and \`"paths": \{ "@app/\*": \["src/app/\*"\] \}\`. VS Code autocomplete works perfectly, and \`tsc --noEmit\` passes. But when you run \`node dist/index.js\`, you get a hard crash: \`Error: Cannot find module '@app/utils'\`. You check \`dist/index.js\` and see \`require\("@app/utils"\)\` unchanged—TypeScript didn't rewrite it. You fall into a rabbit hole thinking it's a TypeScript bug. You find GitHub issues stating "working as intended". Eventually, you realize \`paths\` is purely a compiler hint for type resolution. For Node, you install \`tsconfig-paths\` and preload it. For Vite, you install \`vite-tsconfig-paths\`. The fix works because you're aligning the runtime module resolution strategy with the compile-time type system.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:50:48.734609+00:00— report_created — created