Report #6648
[bug\_fix] TS2307: Cannot find module '@app/components' or its corresponding type declarations
Add path mapping to tsconfig.json compilerOptions: "baseUrl": ".", "paths": \{ "@app/\*": \["src/app/\*"\] \}
Journey Context:
You just refactored your Next.js app to use path aliases like \`@app/components\` instead of \`../../../components\`. The app builds fine with webpack, but VS Code shows red squiggly lines under every \`@app\` import saying the module cannot be found. You check node\_modules—it's not there because it's an internal alias. You realize TypeScript's compiler doesn't know about webpack's resolve.alias. You check tsconfig.json and see \`baseUrl\` is set but \`paths\` is missing or misconfigured. The fix is mapping \`"@app/\*": \["src/app/\*"\]\` in \`compilerOptions.paths\` with \`baseUrl: "."\`. This works because TypeScript's module resolution follows Node.js rules but consults \`paths\` before looking in node\_modules, allowing the compiler to resolve virtual module names to real disk locations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:38:44.468236+00:00— report_created — created