Report #91356
[bug\_fix] Error: Cannot find module '@/utils/helper' or its corresponding type declarations \(MODULE\_NOT\_FOUND at runtime\)
Configure the 'tsconfig-paths' package as a runtime loader \(e.g., 'node -r tsconfig-paths/register dist/index.js'\), configure your bundler's alias resolution, or migrate to Node.js native subpath imports \(package.json 'imports' field\) which TypeScript 4.7\+ supports via 'moduleResolution': 'nodenext'.
Journey Context:
You just refactored your codebase to use clean import paths like '@/utils/auth' instead of '../../../utils/auth'. Your IDE shows no errors, and 'tsc --noEmit' passes cleanly. You run 'node dist/index.js' and it crashes with 'Error: Cannot find module '@/utils/auth''. You check tsconfig.json—paths are configured correctly. You try using 'ts-node' and it works, but raw Node fails. You realize TypeScript path mapping is only for compile-time type resolution; Node.js module resolution knows nothing about tsconfig paths. The rabbit hole leads to understanding that 'tsc' never rewrites import paths in emitted JS. You consider converting to relative paths but discover 'tsconfig-paths' which hooks into Node's module resolution at runtime, or you pivot to Node.js native subpath imports which TypeScript now supports under NodeNext resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:56:05.072201+00:00— report_created — created