Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic component import does not work on a new project v2.15.0 #8851

Closed
PTiCA1 opened this issue Feb 18, 2021 · 8 comments
Closed

Automatic component import does not work on a new project v2.15.0 #8851

PTiCA1 opened this issue Feb 18, 2021 · 8 comments

Comments

@PTiCA1
Copy link

PTiCA1 commented Feb 18, 2021

Versions

  • nuxt: v2.15.0
  • node: v14.13.1

Reproduction

Automatic component imports do not work when you create a new project. The whole project is created by default. I just added scss, bootstrap.
error
Unknown custom element: <Container> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Steps to reproduce

  • Create new component with name

<template><div class="container"><slot /></div></template>
<script> export default { name: "Container" }</script>

  • Insert a new component in page/index.vue
    <Container> test content </Container>

What is Expected?

Component shown

What is actually happening?

I'm getting a console error:
Unknown custom element: <Container> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

If I install version 2.14.12 everything works fine.

Copy link
Member

@PTiCA1 The component name resolution has changed in @nuxt/components - check here for details.

@FelipeModena
Copy link

I am facing the same problem. with the auto import of components, that set in the ~/nuxt/components/index.js, i see my component globoly imported there, but he wont alow me use this component...

in my index.js:
export { default as EditortextoEditorTextoCompleto } from '../..\components\editortexto\EditorTextoCompleto.vue'
export { default as Logo } from '../..\components\Logo.vue'

if i use as a tag component, he allow me, but i i use he wont allow it...

ps: this EditortextoEditorTextoCompleto is not named as it. its oficila name is Editor TextoCompleto.vue, and its in a folder
/components/editortexto/EditortextoEditorTextoCompleto.vue

i still didnt manege to solve it. anyone else?

Copy link
Member

I'm going to close this as I think this is likely just an issue with the new name resolution described here. If the issue persists, please do raise an issue with a reproduction (and consider raising it in that repository).

@toddpadwick
Copy link

toddpadwick commented Sep 2, 2021

Hey @danielroe this is still an issue for me. I have upgraded from 2.15.4 to 2.15.8. All my components are in the root of the components directory. so no possible issues with prefixing as mentioned in that link above.
if i downgrade back to 2.15.4 it works fine. so i dont believe this is an issue relating to the changes made between 2.14 and 2.15 which you are referring to. so something new has changed between 2.15.4 and 2.15.8.

i'll add an issue to the components repo as well.

@danielroe
Copy link
Member

@toddpadwick Would you open a new issue with a reproduction via https://template.nuxtjs.org? 🙏

@storageddd
Copy link

@toddpadwick, @PTiCA1, I have same issue. Solved it after change config.
Before

components: {
    path: '~/components',
    extensions: ['vue'],
    prefix: 'app',
    pathPrefix: false,
    ignore: ['~components/pages', '**/_**']
},

After

components: [
    {
      path: '~/components',
      extensions: ['vue'],
      prefix: 'app',
      pathPrefix: false,
      ignore: ['~components/pages', '**/_**']
    }
  ],

Option components in nuxt.config.js now expects array with object-params.

@toddpadwick
Copy link

toddpadwick commented Feb 4, 2022

Hi @storageddd thanks, I just tried this, but unfortunately still no luck for me.

@danielroe this is not an issue with the name resolution as that change was introduced in version 2.15 and 2.15.4 works fine for me and have been using the name resolution as specified. Versions above 2.15.8 however no longer import components at all whether nested or not.

It looks like many other people are experiencing the same issue and have commented on the ticket that I posted on the components repo.

In my nuxt.config I have:
components:true

in my component library, most of my components are in the root at ~/components/exampleComponent.vue. a few however are also nested such as blocks/nestedComponent.vue.

In my app, I use them as follows, which correct me if I'm wrong, is the expected method:

<template>
    <example-component/>
    <blocks-nested-component/>
</template>

However, for all components whether nested or not, i get Unknown custom element errors.

@danielroe
Copy link
Member

See nuxt/components#230 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants