Report #7206
[bug\_fix] Cannot find module '@/components/Button' or its corresponding type declarations.
Add 'baseUrl': '.' to compilerOptions in tsconfig.json. TypeScript's paths mapping resolves relative to baseUrl; without it, the '@/\*' pattern has no anchor point and resolution silently fails even when paths are correctly defined.
Journey Context:
Developer sets up a new Next.js project and configures path aliases in tsconfig.json: 'paths': \{ '@/\*': \['./src/\*'\] \}. VS Code immediately underlines every alias import with 'Cannot find module'. Developer confirms the files exist at ./src/components/Button.tsx. They try restarting the TypeScript server, reloading the window, and even reinstalling node\_modules. They check the paths syntax ten times, trying './src/\*' vs 'src/\*' vs \['src/\*'\]. Finally, they stumble upon a GitHub issue mentioning that paths resolution requires baseUrl. They add 'baseUrl': '.' to compilerOptions and the errors vanish instantly. The realization hits that TypeScript resolves non-relative paths in 'paths' relative to baseUrl, and without it, the alias has no reference frame.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:09:19.165307+00:00— report_created — created