Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuxt 4 + shadcn/vue Overriding component You can specify a priority option when calling addComponent to avoid this warning warnings for all components

I’m using Nuxt 4 with [email protected], and I’m getting warnings for every shadcn-vue component:

WARN  Overriding StepperDescription component. You can specify a priority option when calling addComponent to avoid this warning.
WARN  Overriding Table component. You can specify a priority option when calling addComponent to avoid this warning.
WARN  Overriding Switch component. You can specify a priority option when calling addComponent to avoid this warning.
... (and so on for all components)

a screnshot for the warnings

---

How can I properly remove or silence these “Overriding component” warnings in a Nuxt 4 project using shadcn-nuxt?

My Nuxt 4 config:

// https://nuxt.com/docs/api/configuration/nuxt-config
import tailwind from '@tailwindcss/vite';

export default defineNuxtConfig({
  devtools: { enabled: true },
  compatibilityDate: '2025-07-15',
  modules: [
    '@nuxt/eslint',
    '@nuxt/fonts',
    'shadcn-nuxt',
    '@vueuse/nuxt',
    '@nuxtjs/color-mode',
  ],
  colorMode: {
    preference: 'system',
    fallback: 'light',
    hid: 'nuxt-color-mode-script',
    globalName: '__NUXT_COLOR_MODE__',
    componentName: 'ColorScheme',
    classPrefix: '',
    classSuffix: '',
    storage: 'localStorage',
    storageKey: 'nuxt-color-mode',
  },
  css: ['~/assets/css/main.css'],
  vite: {
    plugins: [tailwind()],
  },
  eslint: {
    config: {
      formatters: {
        html: 'prettier',
      },
    },
  },
  shadcn: {
    /**
     * Prefix for all the imported component
     */
    prefix: '',
    /**
     * Directory that the component lives in.
     * @default "./components/ui"
     */
    componentDir: '~/components/ui',
  },
  alias: {
    '@components': '~/components',
    '@ui': '~/components/ui',
    '@utils': '~/lib/utils',
  },
});

I also added this to my nuxt.config, but it doesn't resolve the warnings.

...
  components: [
    {
      path: '~/components/ui',
      extensions: ['.vue', '.ts'],
    },
  ],
...

What should I do?

like image 690
Ebraheem Al-hetari Avatar asked Oct 28 '25 19:10

Ebraheem Al-hetari


1 Answers

Hello, there!

I got similar warnings about components "priority" & "resolving same names".
Right now I got those warnings removed by these steps:

  • Removed node_modules, .nuxt and .output from your project

    rm -rf node_modules .nuxt .output
    
  • Updated version of shadcn_nuxt inside package.json to this URL: https://pkg.pr.new/shadcn-nuxt@1418

    // example
    "shadcn-nuxt": "https://pkg.pr.new/shadcn-nuxt@1418"
    
  • Reinstalled dependencies via npm install

    npm install        # `yarn install`, `pnpm install`, `yarn install`, or `bun install`
    
  • Prepare Nuxt again

    # npm
    npx nuxi prepare
    # yarn
    yarn nuxi prepare
    # pnpm
    pnpm exec nuxi prepare
    # bun
    bunx --bun nuxi prepare
    
  • Done!

Thanks and sorry in advance if It could not remove those warnings from your project.


Source:

  • https://github.com/unovue/shadcn-vue/issues/1416#issuecomment-3292757500
  • https://github.com/unovue/shadcn-vue/discussions/1370#discussioncomment-14401143
like image 114
JROCH Avatar answered Oct 30 '25 14:10

JROCH