Report #91117
[bug\_fix] TypeScript path mapping compiles but Node.js runtime throws 'Error: Cannot find module '@app/utils''
TypeScript's paths are compile-time only; Node.js knows nothing of them. Add a post-compilation step using 'tsc-alias' \(npm install --save-dev tsc-alias; modify build script to 'tsc && tsc-alias'\), or migrate to Node.js native subpath imports \(package.json 'imports' field with '\#app/\*' keys\) which TypeScript 4.7\+ resolves natively when moduleResolution is set to 'NodeNext' or 'bundler'.
Journey Context:
You configured compilerOptions.paths so '@app/\*' maps to './src/\*'. VS Code autocompletion works, imports look clean, and tsc exits with no errors. But running node dist/main.js immediately crashes with MODULE\_NOT\_FOUND pointing to require\('@app/utils'\). Inspecting dist/ reveals the alias survived compilation: require\('@app/utils'\) instead of relative paths. You try ts-node and it works \(ts-node hooks into module resolution\), but production builds using vanilla node fail. Searching GitHub issues reveals thousands of similar reports. You realize TypeScript intentionally does not rewrite paths during emit. You add tsc-alias as a post-build step which regex-replaces aliases with relative paths in the emitted JS, or you refactor to use package.json 'imports': \{'\#app/\*': './dist/\*.js'\} and update tsconfig with 'paths': \{'\#app/\*': \['./src/\*'\]\}, which Node.js 12.20\+ and TypeScript 4.7\+ both understand natively.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:32:08.264714+00:00— report_created — created