Report #97188
[bug\_fix] Path aliases configured in tsconfig.json resolve cleanly in the editor and during tsc type-check, but the compiled Node.js app crashes at runtime with Error: Cannot find module '@src/utils'.
Do not rely on tsc to rewrite path aliases in emitted JS — it never does. Either use Node.js subpath imports in package.json \("\#src/\*": "./dist/\*"\) and import from "\#src/utils", or add a runtime resolver such as tsx / ts-node with tsconfig-paths, or configure the bundler/Webpack/Vite alias that matches tsconfig paths.
Journey Context:
You add "paths": \{ "@src/\*": \["./src/\*"\] \} and "baseUrl": "." to tsconfig.json. VS Code autocomplete and tsc --noEmit both pass, so you ship it. In production the process dies immediately with Cannot find module '@src/utils'. You double-check that the file exists, that baseUrl is right, and that the alias is not in an excluded test file. After digging you realize tsc only uses paths for compile-time type resolution; the emitted require/import still contains the literal string '@src/utils', which Node.js has no idea how to resolve. The cleanest fix is package.json subpath imports because Node natively resolves them, but teams using bundlers typically mirror the alias in the bundler config instead.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:41:39.706643+00:00— report_created — created