nuxt / components

Scan and auto import components for Nuxt.js 2.13+
MIT License
887 stars 48 forks source link

Render function or template not defined in component #225

Closed re2005 closed 3 years ago

re2005 commented 3 years ago

Describe the bug

Seems that the module is not working. It runs fine on development, but when build gets an error:

ERROR render function or template not defined in component: {name} 16:56:44

at Yi (node_modules/vue-server-renderer/build.prod.js:1:67000) at oo (node_modules/vue-server-renderer/build.prod.js:1:70873) at no (node_modules/vue-server-renderer/build.prod.js:1:70523) at wt.to [as renderNode] (node_modules/vue-server-renderer/build.prod.js:1:67770) at wt.next (node_modules/vue-server-renderer/build.prod.js:1:20584) at n (node_modules/vue-server-renderer/build.prod.js:1:18796) at node_modules/vue-server-renderer/build.prod.js:1:68881 at to (node_modules/vue-server-renderer/build.prod.js:1:68889) at node_modules/vue-server-renderer/build.prod.js:1:70990 at eo (node_modules/vue-server-renderer/build.prod.js:1:67480)

To Reproduce Steps to reproduce the behavior:

npm run build npm start

Expected behavior Build normally and importing all components on the specified path.

anick-xs commented 3 years ago

I have the same problem

For-ever21 commented 3 years ago

I have the same problem

The name of the registered component is named PascalCase,not use kebab-case

subodhsj commented 3 years ago

I too have same problem, I tried PascalCase, kebab-case and path/prefix in nuxt config nothing worked.

it worked once when I tried this in nuxt.config.js components: ["~/components"],

re2005 commented 3 years ago

Temporarily fix to manually import all your global components:

import { Vue } from 'nuxt-property-decorator';

const files = require.context('../components/Globals', true, /\.vue$/);

files.keys().forEach(file => {
    const componentConfig = files(file);
    const componentName = file.split('/').pop().split('.')[0];
    Vue.component(componentName, componentConfig.default || componentConfig);
});

Add to the plugins

plugins: [
        '~/plugins/global-component-loader.js',
]
subodhsj commented 3 years ago

Describe the bug

Seems that the module is not working. It runs fine on development, but when build gets an error:

ERROR render function or template not defined in component: {name} 16:56:44

at Yi (node_modules/vue-server-renderer/build.prod.js:1:67000) at oo (node_modules/vue-server-renderer/build.prod.js:1:70873) at no (node_modules/vue-server-renderer/build.prod.js:1:70523) at wt.to [as renderNode] (node_modules/vue-server-renderer/build.prod.js:1:67770) at wt.next (node_modules/vue-server-renderer/build.prod.js:1:20584) at n (node_modules/vue-server-renderer/build.prod.js:1:18796) at node_modules/vue-server-renderer/build.prod.js:1:68881 at to (node_modules/vue-server-renderer/build.prod.js:1:68889) at node_modules/vue-server-renderer/build.prod.js:1:70990 at eo (node_modules/vue-server-renderer/build.prod.js:1:67480)

To Reproduce Steps to reproduce the behavior:

npm run build npm start

Expected behavior Build normally and importing all components on the specified path.

are you using "@nuxt/typescript-build" in your project or <script lang="ts" in .vue file?

re2005 commented 3 years ago

Hi @subodhsj yes I'm using that "@nuxt/typescript-build": "^2.1.0", and also nuxt-property-decorator

But mind you that was all working fine just a few days ago. The latest update is exactly a few days ago as well.

subodhsj commented 3 years ago

Hi @subodhsj yes I'm using that "@nuxt/typescript-build": "^2.1.0", and also nuxt-property-decorator

But mind you that was all working fine just a few days ago. The latest update is exactly a few days ago as well.

Thanks @re2005, My other project without @nuxt/typescript-build works fine and Nuxt@v2.15.5 works with typescript.

re2005 commented 3 years ago

So @pi0 you have closed this issue, without the confirmation that by just removing @nuxt/typescript-build" the components module should works just fine ?

pi0 commented 3 years ago

Hi, @re2005. Yes, the issue with the render function should be fixed in v2.2.1. Just remove yarn.lock/package.lock.json and reinstall.