Report #29861
[bug\_fix] Error: Cannot find module '@/utils/helpers' or 'TS2307: Cannot find module '@components/Button'
Install \`tsconfig-paths\` and preload it via \`node -r tsconfig-paths/register dist/index.js\`, or configure your bundler \(Vite/Webpack\) to resolve the alias at build time. TypeScript \`paths\` are compile-time only and are not rewritten in the emitted JS.
Journey Context:
You configured \`paths\` in \`tsconfig.json\` \(e.g., \`"@/\*": \["./src/\*"\]\`\) and your IDE provides perfect autocompletion and go-to-definition. \`tsc --build\` succeeds without errors. However, when you run \`node dist/index.js\`, it crashes with 'MODULE\_NOT\_FOUND' pointing to an import starting with \`@/\`. You inspect \`dist/\` and see \`require\("@/components/Button"\)\` is unchanged. You realize \`tsc\` only uses \`paths\` for type-checking, not for emit. You search for solutions and find \`tsconfig-paths\`, a library that monkey-patches Node's \`Module.\_resolveFilename\` to read your \`tsconfig.json\` paths at runtime, allowing the aliases to resolve correctly without pre-compilation rewriting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:30:49.640395+00:00— report_created — created