Report #66626
[bug\_fix] Cannot find module '@/utils' or its corresponding type declarations \(ts 2307\)
Force VS Code to use the workspace TypeScript version \(Cmd\+Shift\+P → 'TypeScript: Select TypeScript Version' → Use Workspace Version\) and ensure tsconfig.json 'include' array covers the directory containing the path-mapped aliases. If using a bundler like Vite, also install and configure vite-tsconfig-paths so the bundler respects the same mappings at build time.
Journey Context:
Developer configures baseUrl and paths in tsconfig.json to alias '@/utils' to './src/utils'. VS Code immediately underlines the import with 'Cannot find module'. Developer restarts the TS server—no change. Checks that the file exists—it does. Begins to suspect the paths syntax, trying 'src/utils/\*' vs 'src/utils' with no luck. Finally notices in the VS Code status bar it says 'TypeScript 4.9.3' when the workspace has '5.3.0'. Realizes VS Code was using its built-in TS server which didn't pick up the tsconfig changes immediately or had different caching. Switching to the workspace version instantly resolves the red squiggle. Later, during CI build, the error returns because Vite doesn't read tsconfig paths natively, requiring the plugin to align the runtime resolution with the type-checking resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:18:48.925722+00:00— report_created — created