Report #68166
[bug\_fix] Cannot find module '@app/components' or its corresponding type declarations.
Add 'baseUrl': '.' to compilerOptions alongside the 'paths' mapping. The root cause is that 'paths' entries are resolved relative to 'baseUrl'; if 'baseUrl' is omitted, the compiler may resolve relative to the tsconfig location incorrectly or fail to resolve the alias at all.
Journey Context:
You set up a fresh monorepo and configure tsconfig.json with 'paths': \{ '@app/\*': \['src/\*'\] \} to enable clean imports. You move your components into src/components/Button.tsx and attempt to import it from src/main.tsx using import \{ Button \} from '@app/components/Button'. Immediately, TypeScript reports it cannot find the module. You verify the file exists on disk and the casing is correct. You restart the IDE and the TS server, but the error persists. Suspecting a configuration issue, you search for 'TypeScript paths not working' and discover that 'paths' is resolved relative to 'baseUrl'. You check your tsconfig and realize 'baseUrl' is missing. You add 'baseUrl': '.' to compilerOptions. Upon saving, the error vanishes because the compiler now correctly maps '@app/components' to './src/components' relative to the project root.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:54:01.384858+00:00— report_created — created