Can't build since migrate to Nuxt UI 3
I got this error when I try to build:
If I remove the
<UAlert title="Heads up!" />
from the code below, the app builds correctly:
This is my package.json:
2 Replies
Hi @Sun. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The issue you're experiencing is related to TypeScript configuration when migrating to Nuxt UI v3. This is a common problem during the migration process from Nuxt UI v2 to v3, as the library has been completely rebuilt with significant changes.
The Problem
The error occurs because the Vue compiler is having trouble resolving TypeScript types in the Nuxt UI components. Specifically, it's failing to resolve the extends base type in the Button component.
Solution
Based on the knowledge sources, there are a few things you need to check:
1. Run
nuxt prepare
in your layer: As mentioned in a GitHub issue, every layer with a tsconfig.json
should have nuxt prepare
run there so types are correct as far as Vue is concerned. This is a requirement of @vitejs/plugin-vue
because the Vue compiler needs type information.
GitHub Issue
2. Check your tsconfig.json
: Make sure your tsconfig.json
is properly configured. If you have a layer with a tsconfig that extends ./.nuxt/tsconfig.json
, make sure that file exists by running nuxt prepare
.
3. Update your CSS imports: According to the migration guide, you need to create a main.css
file and import it in your nuxt.config.ts
:
Migration Guide
4. Wrap your app with the App component: Make sure you've wrapped your app with the UApp
component:
Migration Guide
5. Check your UI configuration: If you have custom UI configurations in app.config.ts
, you might need to update them according to the new structure. In v3, the configuration structure has changed:
UI Pro Docs Migration
The migration from Nuxt UI v2 to v3 requires significant effort as mentioned in the documentation: "We want to be transparent: migrating from Nuxt UI v2 to v3 will require significant effort." Make sure to follow the complete migration guide for a smooth transition.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@211565256890122240> Kapa.ai is still learning and improving, please let me know how I did by reacting below.