v0 'Module not found: Can't resolve @/components/ui/...' after export
Symptoms
- "Module not found: Can't resolve '@/components/ui/...'" on the first local or Vercel build after export
- npm install fails because package.json lists '@/components' as a dependency
- `npx shadcn@latest add date-picker` says the component isn't in the registry
- The build errors on unknown Tailwind utility classes
- Everything worked perfectly inside v0's preview
Why it happens
Hallucinated shadcn component names
v0 references shadcn components by names that do not exist in the public registry, so `npx shadcn add` has nothing to install. Inside v0's sandbox those components already existed, which is why the preview worked.
Invalid dependencies in package.json
v0 has emitted entries like '@/components' in the dependencies block. That is a TypeScript path alias, not an npm package, and npm install fails on it.
Tailwind version mismatch
Generated CSS written in v3 syntax fails under a v4 install, and vice versa. Mixing the two produces unknown-utility-class errors at build time.
Filename case mismatches
Imports that pass on macOS, where the filesystem is case-insensitive, fail on Vercel's case-sensitive Linux build environment. The error only shows up once you deploy.
How to fix it
- Build locally before you deployRun `npm install && npm run build`. The first 'Module not found' line tells you exactly which import is broken. Fix errors in order; later ones are often side effects of the first.
- Install the missing shadcn/ui componentsFor each missing component, run `npx shadcn@latest add <component-name>`. If the registry says the component does not exist, the name was hallucinated. Swap in the closest real registry component, or copy the component code out of the v0 preview manually.
- Clean up package.jsonDelete invalid entries like '@/components' from the dependencies block. The '@/*' alias belongs in tsconfig.json under 'paths', so make sure it is defined there instead.
- Pin the right Tailwind versionCheck which syntax the generated code uses. If it has tailwind.config.js and @tailwind directives (v3 syntax), pin "tailwindcss": "^3" in package.json, or migrate the config fully to v4 syntax. Do not mix the two.
- Match import paths to file casingMake every import path match the file name casing exactly (Button.tsx vs button.tsx). Vercel builds on Linux, which is case-sensitive; your Mac is not, so this class of error hides until the cloud build.
How to prevent it
- Run `npm run build` locally after every export; never push a fresh ZIP straight to Vercel.
- Check AI-suggested component names against the shadcn registry before assuming they exist; hallucinated names are a known pattern.
- Keep one Tailwind major version per project and pin it in package.json.
- Use consistent lowercase file naming so case-sensitivity differences between macOS and Linux never bite.
Tools that actually fix this
Recommended because they address the failure mode above, not because of the payout. Some are affiliate links; see how we choose.
The best defense against slopsquatting: it flags typosquats, brand-new or suspicious packages, and install-script malware in your pull requests, which is exactly the risk when an AI invents a package name an attacker already registered.
Try Socket →Snyk Code catches injection and XSS right in your editor, and Snyk Open Source flags vulnerable and malicious packages. It covers several AI-code failure modes at once and is free for open source.
Try Snyk →Frequently asked questions
Why does v0 code work in the preview but fail to build locally?
v0 generates code against its own sandbox, where shadcn/ui components and path aliases already exist. On export those assumptions break: components are missing, package.json can contain invalid entries like '@/components', and the Tailwind version may not match. Building locally with `npm install && npm run build` surfaces each gap as a 'Module not found' error you can fix one at a time.
What does 'component not found in registry' mean when I run npx shadcn add?
It means the component name v0 used does not exist in the public shadcn/ui registry; the name was hallucinated. Pick the closest real registry component and adapt it, or copy the working component code directly out of the v0 preview into your components/ui directory.
Why is '@/components' listed in my package.json dependencies?
That is a known v0 export problem: '@/components' is a TypeScript path alias, not an npm package, so npm install fails on it. Delete it from the dependencies block of package.json and define the '@/*' alias in tsconfig.json under 'paths' instead.
Why does the build pass on my Mac but fail on Vercel?
The usual culprit is filename casing. macOS filesystems are case-insensitive, so an import of 'Button' happily resolves to button.tsx locally. Vercel builds on Linux, which is case-sensitive, so the same import fails there. Make import paths match file names exactly.
Sources
- v0 includes '@/components' as a dependency, which is invalid (Vercel Community)
- shadcn add fails: v0 component date-picker not found in registry (Vercel Community)
- Trying to deploy a project from v0 locally using npx shadcn (Vercel Community)
- shadcn/ui discussion #3683 (GitHub)
- Build failed: command npm run build exited with 1 (Rapid Developers)
Related errors
v0 deployment stuck on 'Deploying' (or 'Failed to fetch deployment status')
v0 environment variables undefined: API routes 500 in production but work in preview
Slopsquatting: the AI hallucinated an npm package and an attacker registered it
Replit app works in preview but not deployed (404, blank page)
The Vibe Oops briefing
One email when something ships to production that should not have. New incidents, new error guides, no filler.