Report #92768
[bug\_fix] Cannot find module '@app/utils' or its corresponding type declarations.
Install and register \`tsconfig-paths\` for runtime resolution, or configure your test runner/bundler to resolve the paths alias. For ts-node: \`ts-node -r tsconfig-paths/register\`. For Jest: map the module name in \`moduleNameMapper\`. For Node.js production: use a bundler \(webpack, esbuild\) that respects tsconfig paths during the build, or use \`tsc-alias\` to rewrite the paths in the output. Root cause: TypeScript's \`paths\` configuration is a compile-time only feature that affects the TypeScript compiler's module resolution; it does not modify the emitted JavaScript or instruct the Node.js runtime \(or ts-node's runtime loader\) to perform the same mapping.
Journey Context:
You configure \`baseUrl\` and \`paths\` in \`tsconfig.json\` to avoid deep relative imports like \`../../../utils\`. Your IDE \(VS Code\) now resolves \`@app/utils\` correctly, and \`tsc --noEmit\` reports no errors. You run \`ts-node src/index.ts\` and it crashes with "Cannot find module '@app/utils'". You check that the file exists. You try setting \`TS\_NODE\_PROJECT\` or \`tsconfig-paths\` environment variable but nothing works. You search and find that ts-node doesn't automatically apply path mappings. You find the \`tsconfig-paths\` package. You register it via \`-r tsconfig-paths/register\` and it works. Later, you run Jest tests and they fail with the same error, requiring you to duplicate the path mapping in \`jest.config.js\` under \`moduleNameMapper\`. You realize that path mapping is not universal.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:17:55.547614+00:00— report_created — created