Report #4299
[bug\_fix] TypeScript path aliases not resolved at runtime \(Cannot find module '@/utils'\)
Use Node.js native subpath imports by adding \`"imports": \{"\#\*": "./dist/\*"\}\` to package.json and changing imports to \`\#/utils/logger\`, OR use \`tsx\` \(formerly \`esbuild-runner\`\) which handles tsconfig paths automatically.
Journey Context:
Developer configures TypeScript path mapping in \`tsconfig.json\`: \`"baseUrl": ".", "paths": \{"@/\*": \["./src/\*"\]\}\`. VS Code understands the imports and shows no errors. \`tsc --build\` succeeds. However, when they run \`node dist/index.js\`, it crashes with \`Error: Cannot find module '@/utils/logger'\`. The developer realizes that TypeScript compiles the aliases to JS but doesn't rewrite the import paths, and Node.js doesn't read \`tsconfig.json\`. They try \`ts-node\` but it requires \`tsconfig-paths/register\` flag. They try \`module-alias\` package but it's hacky and doesn't work with ESM. Eventually, they discover Node.js's native subpath imports feature \(package.json "imports" field\). They map \`"\#\*": "./dist/\*"\` and change all source imports from \`@/\` to \`\#/\`. Now both \`tsc\` and Node.js resolve the paths correctly without external tools.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:10:58.732330+00:00— report_created — created