error solved

fix vue failed to mount component: template or render function not defined.


If you are getting failed to mount component: template or render function not defined error. This article will help you to fix the issue.

The most common Solution is that It should be

require('./components/Example.vue').default. 

Since v13, vue-loader exports the component as the default key, which still works the same when using import, but requires the above when using require.

Consider the example below:

let routes = [{
    path: '/contact',
    component: require('./components/Contact.vue').default
  },
  {
    path: '/about',
    component: require('./components/About.vue').default
  }
]

Above we haver added .default to our component requires.


Share on social media

//