Meituan-Dianping/mpvue · error

Failed to mount component: template or render function not d

Error message

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

What it means

Raised from mountComponent when the component has no render option at all: vm.$options.render is falsy, so Vue substitutes createEmptyVNode and (in dev) warns that neither a template nor a render function was resolved. Unlike the runtime-only-build warning, this means the final options contained no compiled render function — typically the component is an empty object, a broken mixin overwrote render, or the file exports nothing usable.

Source

Thrown at src/core/instance/lifecycle.js:158

  vm: Component,
  el: ?Element,
  hydrating?: boolean
): Component {
  vm.$el = el
  if (!vm.$options.render) {
    vm.$options.render = createEmptyVNode
    if (process.env.NODE_ENV !== 'production') {
      /* istanbul ignore if */
      if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
        vm.$options.el || el) {
        warn(
          'You are using the runtime-only build of Vue where the template ' +
          'compiler is not available. Either pre-compile the templates into ' +
          'render functions, or use the compiler-included build.',
          vm
        )
      } else {
        warn(
          'Failed to mount component: template or render function not defined.',
          vm
        )
      }
    }
  }
  callHook(vm, 'beforeMount')

  let updateComponent
  /* istanbul ignore if */
  if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
    updateComponent = () => {
      const name = vm._name
      const id = vm._uid
      const startTag = `vue-perf-start:${id}`
      const endTag = `vue-perf-end:${id}`

      mark(startTag)

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Give the component a template or a render function in its options
  2. Check that the component file actually exports its definition object (default export present, no typo like exporting undefined)
  3. If using runtime-only Vue, ensure the template was pre-compiled; verify mixins or extend chains are not wiping out the render option
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/core/instance/lifecycle.js:158 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02). Data as JSON: /api/errors/e1b592a85043580d. Report an issue: GitHub.