Report #12379
[bug\_fix] Error: Cannot find module '@/utils/helper' at Function.Module.\_resolveFilename \(internal/modules/cjs/loader.js:...\)
Install 'tsconfig-paths' as a dev dependency and preload it via 'node -r tsconfig-paths/register dist/index.js', or migrate to Node.js native subpath imports by defining an 'imports' field in package.json. Root cause: TypeScript's 'paths' mapping is honored only during compilation; the emitted JavaScript retains the alias literal, and Node.js runtime module resolution does not consult tsconfig.json.
Journey Context:
You configured 'paths': \{ '@/\*': \['./src/\*'\] \} in tsconfig.json to eliminate relative import hell. The IDE provides perfect autocompletion, and 'tsc --noEmit' reports zero errors. However, executing 'node dist/server.js' immediately crashes with 'MODULE\_NOT\_FOUND' for '@/utils/helper'. Inspecting 'dist/server.js', you see 'require\("@/utils/helper"\)' or 'import ... from "@/utils/helper"', which Node.js cannot resolve. You attempt to use 'NODE\_PATH=./dist', which fails on Windows and feels brittle. After searching, you discover 'tsconfig-paths', which reads your tsconfig at runtime. You install it and modify your start script to 'node -r tsconfig-paths/register dist/server.js', and the application boots successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:49:56.428856+00:00— report_created — created