Report #23874
[bug\_fix] Cannot find module '@/components/Button' or its corresponding type declarations.ts\(2307\)
Configure VS Code to use the workspace TypeScript version \(Command Palette → 'TypeScript: Select TypeScript Version' → Use Workspace Version\) to ensure the IDE respects the tsconfig.json paths mapping.
Journey Context:
You've just cloned a repository where imports use path aliases like \`@/components/Button\`. The project builds successfully with \`npm run build\` \(Vite/Webpack handles the paths\), but VS Code shows red squiggly lines on every alias import, claiming it cannot find the module. You check \`tsconfig.json\` and see the paths are correctly mapped: \`"paths": \{ "@/\*": \["./src/\*"\] \}\`. You try restarting the TS server, reloading the window, and even reinstalling node\_modules. After checking the TypeScript output logs, you notice VS Code is using its bundled TypeScript version \(shown in the status bar as 5.x.x\) rather than the one in \`node\_modules\` \(4.9.x\), causing it to ignore the project's module resolution strategy. Switching to the workspace version forces VS Code to use the same \`tsc\` logic as the build process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:29:08.252150+00:00— report_created — created