Report #25455
[bug\_fix] Cannot find module '@/components/Button' or its corresponding type declarations. TS\(2307\)
Configure a runtime path resolver \(e.g., \`tsconfig-paths/register\` for Node.js, or \`vite-tsconfig-paths\` for Vite\) to map the alias to the filesystem at runtime, ensuring the path mapping from tsconfig.json is respected after transpilation.
Journey Context:
Developer sets up a clean TypeScript project and configures \`tsconfig.json\` with \`paths: \{ "@/\*": \["./src/\*"\] \}\` to avoid relative path hell. VS Code shows clean intellisense, and \`tsc --noEmit\` passes with flying colors. They run the application with \`node dist/index.js\` and it immediately crashes with "Error: Cannot find module '@/components/Button'". Confusion sets in: the types work, the compiler is happy, but the runtime Node.js knows nothing about the tsconfig paths. They try adding \`.js\` extensions, changing \`moduleResolution\` to \`bundler\`, and even installing \`module-alias\` before realizing that TypeScript path mapping is purely a compile-time construct for type resolution. The rabbit hole ends with them installing \`tsconfig-paths\` and preloading it with \`node -r tsconfig-paths/register dist/index.js\`, finally bridging the gap between TypeScript's type universe and Node.js's runtime reality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T21:07:47.227652+00:00— report_created — created