question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to mount component: template or render function not defined.

See original GitHub issue

laravel mix ver: 1.7.2 node -v : v7.9.0 npm -v: 5.5.1

when npm run watch is called get this problem: Failed to mount component: template or render function not defined.

i want to import child vue to parent vue component get this problem

laravel-mix file content: `let mix = require(‘laravel-mix’);

mix.webpackConfig({ module: { rules: [ { test: /.vue/, loaders: [‘vue-loader’] } ] } });

mix.js(‘resources/assets/js/app.js’, ‘public/js’) .sass(‘resources/assets/sass/app.scss’, ‘public/css’); `

Customers.vue file: `<template> <div class="container"> <div class="row"> <div class="col-md-8 col-md-offset-2"> <div class="panel panel-default"> <div class="panel-heading">Example Component</div>

                <div class="panel-body">
                    <table class="table table-borderd table-striped table-condensed">
                        <thead>
                        <tr>
                            <th>Name:</th>
                            <th>E-mail:</th>
                        </tr>
                        </thead>
                        <tbody>
                            <!--<customer v-for="customer in customerAll" :product="customer"></customer>-->
                            <customer :product="customers"></customer>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</template> <script> import Customer from './Customer.Vue'; export default { data() { return { customerAll: [] } }, components:{ "customer":Customer, } , methods:{ fetchUser(){ this.$http.get("customer").then(response => {this.customerAll = response.data.customers}) } }, created(){ this.fetchUser() }, mounted() { console.log('Component mounted.') } } </script>

package.json file: { “private”: true, “scripts”: { “dev”: “npm run development”, “development”: “cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js”, “watch”: “cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js”, “watch-poll”: “npm run watch – --watch-poll”, “hot”: “cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js”, “prod”: “npm run production”, “production”: “cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js” }, “devDependencies”: { “axios”: “^0.17”, “bootstrap-sass”: “^3.3.7”, “cross-env”: “^5.1”, “jquery”: “^3.2”, “laravel-mix”: “^1.0”, “lodash”: “^4.17.4”, “node-sass”: “^4.7.2”, “vue”: “^2.5.7”, “vue-resource”: “^1.3.5” } } Customer.vue file content: <template> <div>

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa debitis eius exercitationem iste possimus quis similique veniam vero. Aliquam autem ea eos ipsa itaque iusto labore libero magni quaerat quod!

</div> </template>

<script> export default { props:["product"] } </script>

app.js file: require(‘./bootstrap’); import VueResource from ‘vue-resource’; window.Vue = require(‘vue’);

Vue.use(VueResource);

Vue.component(‘app’, require(‘./components/Customers.vue’));

const app = new Vue({ el: ‘#app’ }); `

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (7 by maintainers)

github_iconTop GitHub Comments

12reactions
scheMeZacommented, Jan 16, 2019

I fixed my problem, I use and register all of my vue components:

From:

const files = require.context('./components', true, /\.vue$/i);
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key)));

To:

const files = require.context('./components', true, /\.vue$/i);
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));

This translates to:

Vue.component('example-component', require('./components/ExampleComponent.vue').default);
4reactions
ankurk91commented, Jan 8, 2018

@tmediaa Rename your Customer.Vue to Customer.vue, notice the extension should be lowercase .vue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue template or render function not defined yet I am using ...
This error: [Vue warn]: Failed to mount component: template or render function not defined. You're getting because of a certain problem that's ...
Read more >
[Vue warn]: Failed to mount component: template or render ...
I have no issues, when I run the project, but I just setup the vue-test-utils using Vue Cli 4 , and tried my...
Read more >
Failed to mount component: template or render function not ...
A render function takes an argument which itself is a function. This function creates you a vnode. The render function expects you to...
Read more >
Laravel + Vue.js - template or render function not defined.
Hi, I am trying to use vue-router links to load my home and about.vue but I get this error: app.js:64725 [Vue warn]: Failed...
Read more >
Gantt chart - Failed to mount component: template or render ...
Hello. I get an error when using Gantt charts in nuxt. Please let me know how to solve this problem. ## message. [Vue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found