Meituan-Dianping/mpvue · error

Vue is a constructor and should be called with the `new` key

Error message

Vue is a constructor and should be called with the `new` keyword

What it means

Emitted from the Vue constructor function itself when it is invoked without 'new' (the 'this instanceof Vue' check fails) in non-production builds. Calling Vue() as a plain function leaves 'this' undefined/global, so the immediately following this._init(options) call would throw a more confusing TypeError; this dev-only guard catches the mistake early. Note the constructor still proceeds and will crash right after the warning.

Source

Thrown at src/core/instance/index.js:12

import { initMixin } from './init'
import { stateMixin } from './state'
import { renderMixin } from './render'
import { eventsMixin } from './events'
import { lifecycleMixin } from './lifecycle'
import { warn } from '../util/index'

function Vue (options) {
  if (process.env.NODE_ENV !== 'production' &&
    !(this instanceof Vue)
  ) {
    warn('Vue is a constructor and should be called with the `new` keyword')
  }
  this._init(options)
}

initMixin(Vue)
stateMixin(Vue)
eventsMixin(Vue)
lifecycleMixin(Vue)
renderMixin(Vue)

export default Vue

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Instantiate with new: const app = new Vue({...})
  2. For component code paths use Vue.extend or registration options instead of calling Vue directly
  3. Check for calls like Vue(options) or Vue().mount('#app') in your bootstrap code
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/core/instance/index.js:12 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/470d85dbf3ae33f2. Report an issue: GitHub.