如何修复 Laravel Spark v4.0.9 上的“Vue 包版本不匹配”错误?

新手上路,请多包涵

当我在 Laravel Spark v4.0.9 应用程序上运行 npm run dev 时,我收到以下错误:

 Module build failed: Error:

Vue packages version mismatch:

- vue@2.0.8
- vue-template-compiler@2.2.6

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

我的 package.json 看起来像这样:

 {
  "private": true,
  "scripts": {
    "dev": "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",
    "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",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "dependencies": {
    "axios": "^0.15.2",
    "bootstrap": "^3.0.0",
    "cross-env": "^3.2.3",
    "jquery": "^2.1.4",
    "js-cookie": "^2.1.0",
    "laravel-mix": "0.*",
    "moment": "^2.10.6",
    "promise": "^7.1.1",
    "sweetalert": "^1.1.3",
    "underscore": "^1.8.3",
    "urijs": "^1.17.0",
    "vue": "~2.0.1",
    "vue-resource": "^1.2.0",
    "vue-router": "^2.2.1",
    "vue-truncate-filter": "^1.1.6",
    "vuejs-datepicker": "^0.6.2"
  },
  "devDependencies": {
    "browser-sync": "^2.18.8",
    "browser-sync-webpack-plugin": "^1.1.4"
  }
}

我尝试了以下方法(在不同的时间,不按顺序):

  • 删除 node_modulesnpm install
  • 尝试运行 yarnyarn upgrade
  • 删除 vue-loader 并重新安装
  • 指定 vue 和 vue-template-compiler 的确切版本,而不是让 npm 来安装或由 yarn 来找出依赖关系
  • 删除其他非必要的包(vue-router、vue-truncate-filter、vuejs-datepicker)并再次尝试以上所有
  • 把我的头撞在墙上

原文由 Nate Ritter 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 772
2 个回答

这对我有用:

  1. 修改 package.json
    “vue”: “^2.0.8",
   “vue-template-compiler”: “^2.1.8"

  1. 删除 node_modules

  2. 运行 npm install

原文由 Espen 发布,翻译遵循 CC BY-SA 3.0 许可协议

对于 vue ^2.5.17

在你的 package.json

只需将其添加到 devDependencies 或更新 vue-template-compiler 的版本:

  • "vue-template-compiler": "^2.5.17"

你会得到这个输出:

 "devDependencies": {
  ...
  "lodash": "^4.17.4",
  "popper.js": "^1.14.4",
  "vue": "^2.5.17", // <= note the version
  "vue-template-compiler": "^2.5.17" // <= note the version
},

之后,运行:

 npm install

Npm 将只更新更新的包。

原文由 Jose Seie 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题