vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.58k stars 4.76k forks source link

Unknown custom element for Layout #1426

Closed mathieutu closed 5 years ago

mathieutu commented 5 years ago

Bug report

Version

v1.0.0-alpha.44

Steps to reproduce

What is expected?

A new component in theme/layouts directory should be available as layout.

What is actually happening?

Sometimes when navigating through the app, a page is not loaded, and an "Unknown custom element" error is thrown.

It can be a custom layout or not.

The page is ok if I refresh it.

It don't know how to reproduce the bug and find a proper pattern for that.

[Vue warn]: Unknown custom element: <Tag> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
       <Root>
[Vue warn]: Unknown custom element: <v-b2bf5494> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Content>
       <Page> at node_modules/@vuepress/theme-default/components/Page.vue
         <ParentLayout> at node_modules/@vuepress/theme-default/layouts/Layout.vue
           <Layout> at .vuepress/theme/layouts/Layout.vue
             <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
               <Root>

---> <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
       <Root>
[Vue warn]: Unknown custom element: <Post> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
       <Root>

Other relevant information

I'm using the blog plugin, and it adds some layout automatically to pages.

All my Layout components have a name key.

shigma commented 5 years ago

Don't use words like sometimes. You should tell us how.

If the situation you mentioned only occurs after modifying config.js, then this is a known issue.

mathieutu commented 5 years ago

@Shigma It's why it was actually emphasized, and why there is a mention:

It don't know how to reproduce the bug and find a proper pattern for that.

It was on purpose to tell you that I have no idea of the why or how. But now you told me that it can be after updating config.js, I will pay attention of that, and will be able to confirm it to you.

😉

ulivz commented 5 years ago

A new component added in theme/layouts will not trigger reloading so your new layout will not be available, and you need to watch it by yourself or re-launch your dev server.

jessemarple commented 5 years ago

In my case, the issue was simply a hanging comma in the config file. Very strange.

bill-dou commented 2 years ago

I still can have the issue in Vuepress v1.9.7. I even tried the Vuepress docs codebase and same problem.

[Vue warn]: Unknown custom element: <v-7324b362> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
krofax commented 1 year ago

@bill-dou have you gotten some help on this?

bill-dou commented 1 year ago

@krofax yes, I got a solution.

EnhanceApp.js

import pageComponents from '@internal/page-components'

export default ({ Vue }) => {
  for (const [name, component] of Object.entries(pageComponents)) {
    Vue.component(name, component)
  }
}