Report #54622
[bug\_fix] Error: Cannot find module '@/utils/helper' at Function.Module.\_resolveFilename
Install tsconfig-paths as a dev dependency and preload it via Node.js loader: \`node -r tsconfig-paths/register dist/index.js\`. Root cause: TypeScript's \`paths\` configuration only affects compile-time module resolution \(tsc\), not runtime Node.js module resolution. Node.js doesn't read tsconfig.json, so you need a runtime interceptor to resolve the mapped paths to actual file system locations.
Journey Context:
You just refactored your Express API to use path aliases \(\`@/utils\`, \`@/types\`\) to avoid \`../../../\` hell. \`tsc\` builds successfully, but when you run \`node dist/server.js\`, it crashes immediately with 'Cannot find module '@/utils/helper''. You check \`dist/utils/helper.js\` exists. You try using relative paths in the import - it works. You realize the compiled JS still has the \`@/\` prefix. You search 'TypeScript path alias runtime' and find StackOverflow answers mentioning \`tsconfig-paths\`. You try \`node -r tsconfig-paths/register\` and it works. You then configure your production Dockerfile to include the register flag, realizing that without it, the path mappings exist only in the TypeScript compiler's imagination, not in Node's module resolver.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:10:45.390575+00:00— report_created — created