index.js:13 Uncaught TypeError: Cannot read property 'split' of undefined

使用 webpack 编译 Vue 项目时出现报错:


index.js:13 Uncaught TypeError: Cannot read property 'split' of undefined

定位错误到事发代码行:

version = Vue.version.split('.').map(Number)

这行代码是`vue-hot-reload-api`中的,查阅其官方(说明)[https://github.com/vuejs/vue-hot-reload-api#vue-hot-reload-api],明确指出:

vue-hot-reload-api@2.x only works with vue@2.x

幡然醒悟,此项目确实是正在从 Vue1.x 向 Vue2.x 迁移。

在编译过程有一句提示:vue-template-complier 和 vue-loader 版本要保持一致。