Report #92389
[bug\_fix] Error: Cannot find module '@/utils/helpers' or TS2307: Cannot find module '@/utils/helpers'.
Configure 'baseUrl' and 'paths' in tsconfig.json, then ensure runtime module resolution matches by using 'tsconfig-paths/register' \(for Node.js\), configuring bundler aliases \(Vite/Webpack\), or using 'tsc-alias' post-compilation. TypeScript path mapping is compile-time only; it does not rewrite require/import paths in emitted JavaScript.
Journey Context:
Your codebase has grown and relative imports like \`../../../utils/helpers\` are unmaintainable. You configure tsconfig.json with \`baseUrl: '.'\` and \`paths: \{ '@/\*': \['./src/\*'\] \}\`. VS Code immediately starts resolving \`@/utils/helpers\` correctly, and TypeScript compilation succeeds. You run \`node dist/index.js\` and it crashes with 'Cannot find module '@/utils/helpers''. You check the compiled JS—the import is still \`require\('@/utils/helpers'\)\`. You realize TypeScript never rewrites these paths for Node.js runtime. You search for solutions and find \`tsconfig-paths\`. You install it and run \`node -r tsconfig-paths/register dist/index.js\` and it works. Alternatively, if using a bundler like Vite, you configure the alias there too. You understand now that TypeScript paths are just type-checking hints, not runtime transformations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:39:51.845711+00:00— report_created — created