Report #92978
[bug\_fix] Cannot find module '@/utils/helpers' or its corresponding type declarations.
TypeScript path mapping is compile-time only; it does not rewrite emitted module specifiers. Install and register \`tsconfig-paths\` \(e.g., \`node -r tsconfig-paths/register dist/index.js\`\) to provide runtime resolution, or use a bundler \(Webpack, Vite, esbuild\) that reads paths during the build. Alternatively, replace path aliases with relative paths in the source if not using a build step.
Journey Context:
Developer configures \`paths\` in tsconfig.json \(e.g., \`"@/\*": \["./src/\*"\]\`\) and sees VS Code perfectly resolve \`import \{ foo \} from '@/utils/foo'\` with full IntelliSense. However, running \`ts-node src/index.ts\` or executing compiled output with Node immediately throws \`Error: Cannot find module '@/utils/foo'\`. The developer restarts the TS server, triple-checks baseUrl, and tries adding \`"rootDir": "."\` to no avail. After searching, they discover that TypeScript's \`paths\` is purely a compiler construct for locating type definitions during type-checking and declaration emit; the emitted JavaScript retains the original import specifier \(e.g., \`require\('@/utils/foo'\)\`\). Since Node.js knows nothing about tsconfig paths, resolution fails. The fix requires either a runtime loader \(\`tsconfig-paths\`\) that patches Node's \`Module.\_resolveFilename\`, or a build tool that physically rewrites the import paths during transpilation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:39:01.303687+00:00— report_created — created