Import errors in V0 projects occur because of three main issues: @/ path alias misconfiguration in exported code, esm.sh module resolution failures in V0's preview sandbox, and missing npm packages that V0 references but does not install. Fix these by verifying tsconfig.json path aliases match the @/ imports, checking package availability on esm.sh before relying on it in preview, and installing all missing dependencies after exporting.
Why import errors happen in V0 projects
V0 generates code with @/ import paths (like @/components/ui/button) that rely on TypeScript path aliases configured in tsconfig.json. These work in V0's sandbox but fail when code is exported to projects without the alias configured, or when the project structure does not match V0's expected layout. The second major source of import errors is esm.sh — V0's preview sandbox resolves npm packages through this CDN, and some packages (Phaser, @supabase/ssr, certain AI SDK packages) fail to load because they lack ESM-compatible builds. The third issue is V0 referencing packages in import statements without actually adding them to package.json, which only surfaces when you run npm install locally.
- V0 uses @/ import paths that require tsconfig.json path alias configuration not present in exported projects
- esm.sh in V0's preview cannot resolve packages with CommonJS-only builds or complex dependencies
- V0 generates imports for packages not listed in package.json, relying on sandbox pre-installation
- shadcn component references point to registry entries that do not exist (date-picker, toaster, color-picker)
- Relative import paths break when V0 moves or renames files during regeneration
Error messages you might see
Module not found: Error: Can't resolve '@/components/ui/button'The @/ path alias is not configured in tsconfig.json. V0 assumes Next.js path aliases are set up. Add the paths configuration to tsconfig.json to map @/ to your source directory.
Cannot find module '@/lib/utils' or its corresponding type declarations.The utils file is either missing from the project or the @/ alias does not resolve to the correct directory. Check that lib/utils.ts exists and tsconfig.json has the correct baseUrl and paths.
Attempted import error: 'phaser' does not contain a default export (imported as 'Phaser')esm.sh cannot convert the Phaser package to a proper ESM module. Use a CDN script tag instead, or this import will work after exporting to a normal npm-based project.
You are not authorized to access the component at https://v0.dev/chat/b/xxxxxxx/json.The npx v0 add command requires authentication that is no longer included in the URL. Download the project as ZIP instead, or use the GitHub integration.
Error: The file "/components/mode-toggle" cannot be found (imported in "/components/Navbar").V0 references a component that was either deleted during regeneration or never created. Create the missing file or update the import to point to the correct location.
Before you start
- A V0 project with import errors in the preview or after export
- Access to the V0 code editor for inspecting import paths and package.json
- Basic understanding of TypeScript path aliases and npm package resolution
How to fix it
Configure @/ path alias in tsconfig.json
V0 generates all imports using the @/ prefix which maps to the project root. This is standard in Next.js but must be explicitly configured. Without it, TypeScript and the bundler cannot resolve @/components/... imports.
Configure @/ path alias in tsconfig.json
V0 generates all imports using the @/ prefix which maps to the project root. This is standard in Next.js but must be explicitly configured. Without it, TypeScript and the bundler cannot resolve @/components/... imports.
Open tsconfig.json and add the baseUrl and paths configuration. In Next.js App Router projects, @/ should map to the project root or the src directory if you use one.
{ "compilerOptions": { "target": "es5", "lib": ["dom", "esnext"], "strict": true }}{ "compilerOptions": { "target": "es5", "lib": ["dom", "esnext"], "strict": true, "baseUrl": ".", "paths": { "@/*": ["./*"] } }}Expected result: All @/components/..., @/lib/..., and @/app/... imports resolve correctly. TypeScript shows no module-not-found errors.
Install missing npm packages
V0's sandbox has many packages pre-installed that are not listed in package.json. After exporting, these packages are missing and imports fail. Running the build locally reveals which packages need to be added.
Install missing npm packages
V0's sandbox has many packages pre-installed that are not listed in package.json. After exporting, these packages are missing and imports fail. Running the build locally reveals which packages need to be added.
Run npm run build and note every Module not found error. Install each missing package. For shadcn components that fail to install from the registry, download the project as ZIP which includes V0's custom implementations.
// Build errors:// Module not found: Can't resolve 'canvas-confetti'// Module not found: Can't resolve 'date-fns'// Module not found: Can't resolve 'lucide-react'// Install missing packages:// npm install canvas-confetti date-fns lucide-react// npm install -D @types/canvas-confettiExpected result: All package imports resolve. The build proceeds past the module resolution phase.
Handle esm.sh failures in V0 preview
V0's preview resolves npm packages through esm.sh, which fails for packages without ESM builds, packages with native bindings, or packages with complex dependency chains. These errors only occur in V0's preview — the packages work fine after export.
Handle esm.sh failures in V0 preview
V0's preview resolves npm packages through esm.sh, which fails for packages without ESM builds, packages with native bindings, or packages with complex dependency chains. These errors only occur in V0's preview — the packages work fine after export.
When a package fails to load in V0 preview, check if it has an ESM build by visiting https://esm.sh/package-name. If it fails, use one of three workarounds: load via CDN script, use a compatible alternative package, or accept it will not work in preview but will work after export.
// Fails in V0 preview:import { createBrowserClient } from "@supabase/ssr"// Error: Import Error | Failed to load "@supabase/ssr"// Workaround for V0 preview:import { createClient } from "@supabase/supabase-js"const supabase = createClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!)// After export, switch to @supabase/ssr for proper SSR supportExpected result: The Supabase client works in V0 preview using the browser SDK. After exporting, you can switch to the SSR-optimized package.
Fix shadcn component registry import errors
V0 references shadcn components by registry URL, but some components (date-picker, toaster, color-picker) do not exist in the current registry. This causes npx shadcn add to fail.
Fix shadcn component registry import errors
V0 references shadcn components by registry URL, but some components (date-picker, toaster, color-picker) do not exist in the current registry. This causes npx shadcn add to fail.
For missing registry components, download the V0 project as ZIP instead of using the CLI. The ZIP includes V0's custom implementations of these components. Alternatively, build the component from its constituent parts (e.g., date-picker from Popover + Calendar).
// This fails:// npx shadcn add "https://v0.dev/chat/b/xxx/json"// Error: component not found in registry// Download as ZIP from V0 instead// OR install the component parts:// npx shadcn add popover calendar// npx shadcn add sonner (replaces toast/toaster)Expected result: All shadcn components are available in your project. Imports resolve correctly and components render as designed.
Complete code example
1{2 "compilerOptions": {3 "target": "ES2017",4 "lib": ["dom", "dom.iterable", "esnext"],5 "allowJs": true,6 "skipLibCheck": true,7 "strict": true,8 "noEmit": true,9 "esModuleInterop": true,10 "module": "esnext",11 "moduleResolution": "bundler",12 "resolveJsonModule": true,13 "isolatedModules": true,14 "jsx": "preserve",15 "incremental": true,16 "plugins": [17 {18 "name": "next"19 }20 ],21 "baseUrl": ".",22 "paths": {23 "@/*": ["./*"]24 }25 },26 "include": [27 "next-env.d.ts",28 "**/*.ts",29 "**/*.tsx",30 ".next/types/**/*.ts"31 ],32 "exclude": ["node_modules"]33}Best practices to prevent this
- Always verify tsconfig.json has @/ path alias configured when setting up a V0 export locally
- Run npm run build locally after export to catch all missing packages before deploying
- Download V0 projects as ZIP when npx shadcn add fails for specific components
- Check esm.sh compatibility before relying on a package in V0 preview — visit https://esm.sh/package-name
- Keep a consistent import style (@/ for project files, package names for node_modules) across all V0 components
- Install @types packages for every untyped npm dependency to prevent TypeScript build failures
- Use npx shadcn add for individual components instead of the deprecated npx v0 add command
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
My V0 exported Next.js project has import errors: @/components/ui/button is not found, some npm packages are missing, and npx shadcn add fails for date-picker. How do I fix all these import issues? I need the tsconfig.json alias config, missing package list, and shadcn workarounds.
Frequently asked questions
Why does @/components/ui/button fail after exporting V0 code?
The @/ import path is a TypeScript alias that maps to the project root. V0's sandbox has this configured, but your local project may not. Add baseUrl: '.' and paths: { '@/*': ['./*'] } to the compilerOptions in tsconfig.json.
What is esm.sh and why does it cause import errors?
esm.sh is a CDN that converts npm packages to ES modules on the fly. V0's preview sandbox uses it to resolve imports. Some packages (Phaser, @supabase/ssr, certain AI SDKs) do not convert cleanly, causing import errors in preview. These packages work fine after exporting to a normal Next.js project with npm.
How do I fix shadcn components that are not in the registry?
Download the V0 project as ZIP instead of using npx shadcn add. The ZIP includes V0's custom implementations of components like date-picker and toaster. Alternatively, install the component parts (npx shadcn add popover calendar) and compose them yourself.
Why does npx v0 add require authentication?
The npx v0 add command has been largely deprecated since the February 2026 update. Use GitHub integration (Git panel > Connect) or download as ZIP instead. The CLI authentication issue was a known bug.
How do I find which packages are missing from package.json?
Run npm run build locally. Every Module not found error lists the missing package. Install them with npm install package-name. For type definitions, add npm install -D @types/package-name.
Can RapidDev resolve import errors in my V0 export?
Yes. V0 export issues often involve multiple interacting problems — path aliases, missing packages, registry mismatches, and esm.sh incompatibilities. RapidDev engineers can diagnose all import errors systematically and get your exported project building cleanly.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your issue.
Book a free consultation