Report #6520
[bug\_fix] Cannot find module '@app/shared' or its corresponding type declarations at runtime despite successful compilation
Install tsconfig-paths as a dev dependency and preload it via \`node -r tsconfig-paths/register dist/index.js\`, or register it programmatically at the entry point. Root cause: TypeScript path mappings are compile-time abstractions; the Node.js runtime module resolution algorithm does not consult tsconfig.json, so it fails to resolve the bare specifier at runtime.
Journey Context:
Developer configures a monorepo with tsconfig paths mapping \`@app/shared\` to \`../shared/src\`. The TypeScript compiler and IDE IntelliSense work perfectly, suggesting auto-imports and resolving types. However, running \`node dist/apps/server/index.js\` immediately crashes with MODULE\_NOT\_FOUND. Developer inspects the compiled JavaScript and sees \`require\('@app/shared'\)\`, realizing Node.js has no knowledge of the alias. They search for 'typescript paths runtime' and find references to tsconfig-paths. After installing it and adding the preload flag, the application starts, confirming that the runtime needs an explicit resolver hook to mirror the compiler's logic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:17:20.966614+00:00— report_created — created