Report #26479
[bug\_fix] Cannot find module '@/components/Button' or its corresponding type declarations. ts\(2307\)
Configure 'paths' and 'baseUrl' in tsconfig.json, ensure VS Code uses the workspace TypeScript version, and use a runtime that respects path mapping \(tsx/ts-node\) or configure bundler aliases to match.
Journey Context:
Developer migrates a Next.js app to a monorepo with packages/ui and packages/web. They add 'paths': \{ '@ui/\*': \['../ui/src/\*'\] \} to web/tsconfig.json. VS Code underlines @ui/components with 'Cannot find module'. They verify the JSON syntax is valid. Running tsc --noEmit shows the same error. They realize 'baseUrl' must be explicitly set for relative paths to resolve, setting 'baseUrl': '.'. The terminal now passes but VS Code still shows red squiggles. They notice the VS Code status bar shows 'TypeScript 4.5.4' instead of 'workspace version'. Clicking it and selecting 'Use Workspace Version' clears the IDE errors. However, running node dist/index.js fails with 'Cannot find module @ui/components'. They realize Node.js doesn't understand TypeScript path mapping natively. They install 'tsx' \(or 'tsconfig-paths/register'\) which respects tsconfig paths during execution, resolving the runtime error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:50:56.530675+00:00— report_created — created