Report #13751
[bug\_fix] Cannot find module '@app/utils' or its corresponding type declarations at runtime despite successful TypeScript compilation
Install and register \`tsconfig-paths\` \(for ts-node\) or use a bundler that respects tsconfig paths. Root cause: TypeScript's path mapping is a compile-time only feature; Node.js runtime resolution does not read tsconfig.json, so compiled JS fails when resolving non-relative imports.
Journey Context:
Developer configures path mapping in tsconfig.json \(e.g., \`"@app/\*": \["src/\*"\]\`\) to avoid relative path hell \(\`../../../\`\). IDE autocompletion works perfectly, and \`tsc --noEmit\` passes cleanly. However, running \`node dist/index.js\` immediately crashes with "Error: Cannot find module '@app/utils'". Developer suspects a build output issue and checks that \`outDir\` is set correctly. They try manually editing the compiled JS to use relative paths, which works, confirming the issue is resolution, not compilation. Searching the error leads to GitHub issues explaining that Node.js knows nothing about tsconfig paths. Developer discovers \`tsconfig-paths\` package \(or \`tsx\`/\`ts-node\` with \`--project\` flags\) which patches the require resolution at runtime, or alternatively migrates to Node.js native subpath imports \(package.json "imports" field\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:43:04.890891+00:00— report_created — created