nuxt: Auto import of components broken

Environment

  • Operating System: Linux
  • Node Version: v16.14.0
  • Nuxt Version: 3.0.0-27429889.e45a780
  • Package Manager: yarn@1.22.17
  • Bundler: Vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/jiblett1000/test

Describe the bug

With the latest update on npm as of this writing, auto importing of components seems to be completely broken. I’ve linked a reproduction with a fresh nuxt3 install with a single component in the components directory. Running yarn dev results in this error:

[Vue warn]: Failed to resolve component: Test If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 13
  • Comments: 16 (4 by maintainers)

Most upvoted comments

This error was driving me crazy, good thing that I decided to search on GitHub issues and not give up on it 😂

This isn’t a dependency issue - it’s resolved by nuxt/framework#3396, and you can work around for the moment by configuring components: { global: true }. Make sure to revert that change after that PR is merged.

I tried adding this to my nuxt config however it does not seem to work for me. 😟

You temporarily need to roll back to an older version yarn add -D nuxt3@3.0.0-27428764.271289c

or you can temporarily just add those lines in your nuxt.config it should work

  components: {
    global: true,
    dirs: ['~/components']
  }

Glad to see its not only me.

This isn’t a dependency issue - it’s resolved by https://github.com/nuxt/framework/pull/3396, and you can work around for the moment by configuring components: { global: true }. Make sure to revert that change after that PR is merged.

Problem solved! I deleted the node_modules directory, package-lock.json and the npm cache and reinstalling the npm packages the problem went away.

@smorcuend this work for me, thanks!

Problem solved! I deleted the node_modules directory, package-lock.json and the npm cache and reinstalling the npm packages the problem went away.

or you can temporarily just add those lines in your nuxt.config it should work

  components: {
    global: true,
    dirs: ['~/components']
  }

Thanks! Adding the dirs option seems to do the trick. 👍