Vue软件包版本不匹配

时间:2019-04-29 16:01:33

标签: vue.js jestjs

我试图通过玩笑将单元测试添加到现有的vue项目中,但是当我尝试运行我的第一个测试时,我得到一个错误提示

  

Vue软件包版本不匹配:

- vue@2.5.16
- vue-template-compiler@2.6.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.

但是查看我的软件包,我当前的vue版本是 2.6.6而不是2.5.16。我不知道它在哪里看到这个2.5.16版本。我没有在全球范围内安装vue,只有@ vue / cli @ 3.4.0。任何帮助,将不胜感激。在下面,您可以找到包含我的笑话配置的package.json。

{
  "version": "1.0.0",
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "@babel/core": "^7.4.0",
    "@tinymce/tinymce-vue": "^1.1.0",
    "@types/bootstrap": "^3.3.40",
    "@types/jest": "^24.0.11",
    "@types/jquery": "^2.0.51",
    "@types/jquery.validation": "^1.16.5",
    "@types/jqueryui": "^1.12.6",
    "@types/kendo-ui": "^2018.3.0",
    "@types/knockout": "^3.4.60",
    "@types/moment": "^2.13.0",
    "axios": "^0.18.0",
    "axios-cache-adapter": "^2.1.1",
    "browser-detect": "^0.2.28",
    "es6-promise": "^4.2.5",
    "file-saver": "^1.3.8",
    "knockout": "^3.4.2",
    "moment-timezone": "^0.5.23",
    "query-string": "^6.2.0",
    "tinymce-vue": "^1.0.0",
    "url-search-params-polyfill": "^5.0.0",
    "vee-validate": "^2.1.3",
    "vue": "^2.6.6",
    "vue-class-component": "^6.3.2",
    "vue-multiselect": "^2.1.3",
    "vue-notification": "^1.3.13",
    "vue-property-decorator": "^7.2.0",
    "vue-router": "^3.0.2",
    "vuejs-datepicker": "^1.5.4",
    "vuex": "^3.0.1",
    "vuex-persistedstate": "^2.5.4"
  },
  "scripts": {
    "dev": "webpack --mode development --watch --hot",
    "test": "npm run test:unit",
    "test:unit": "jest",
    "build": "webpack --mode production",
    "output": "webpack --profile --json > stats.json"
  },
  "devDependencies": {
    "@types/file-saver": "^1.3.1",
    "@vue/test-utils": "^1.0.0-beta.29",
    "babel-core": "^6.26.3",
    "babel-jest": "^24.7.1",
    "babel-loader": "^8.0.4",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-3": "^6.24.1",
    "css-loader": "^1.0.1",
    "hard-source-webpack-plugin": "^0.13.1",
    "jest": "^23.4.2",
    "node-sass": "^4.10.0",
    "printd": "^1.0.1",
    "sass-loader": "^7.1.0",
    "ts-jest": "^23.10.5",
    "ts-loader": "^4.5.0",
    "typescript": "^3.2.1",
    "uglifyjs-webpack-plugin": "^2.0.1",
    "vue-jest": "^3.0.4",
    "vue-loader": "^15.4.2",
    "vue-template-compiler": "^2.6.6",
    "webpack": "^4.28.4",
    "webpack-bundle-analyzer": "^3.0.3",
    "webpack-cli": "^3.1.2",
    "webpack-hot-middleware": "^2.24.3"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "ts",
      "json",
      "vue"
    ],
    "moduleDirectories": [
      ".",
      "<rootDir>/Scripts",
      "<rootDir>/Scripts/VueModules",
      "<rootDir>/Scripts/VueModules/SharedComponents",
      "<rootDir>/Scripts/VueModules/Candidates/",
      "node_modules"
    ],
    "moduleNameMapper": {
      "^@candidates$": "<rootDir>/Scripts/VueModules/Candidates",
      "^@shared$": "<rootDir>/Scripts/VueModules/SharedComponents",
      "^@app$": "<rootDir>/Scripts/VueModules",
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/Scripts/VueModules/__mocks__/fileMock.js",
      "\\.(css|less|scss|sass)$": "<rootDir>/Scripts/VueModules/__mocks__/styleMock.js"
    },
    "transform": {
      ".*\\.(vue)$": "vue-jest",
      "^.+\\.tsx?$": "ts-jest"
    },
    "transformIgnorePatterns": [
      "node_modules/(?!vue)"
    ],
    "testURL": "http://localhost/",
    "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$"
  }
}

2 个答案:

答案 0 :(得分:2)

npm update为我解决了相同的问题。

答案 1 :(得分:0)

您的package.json中有"vue": "^2.6.6","vue-template-compiler": "^2.6.6",,这意味着将安装与 2.6.6 或更高版本匹配的任何说明vue@2.5.16的版本。您的package-lock.json文件设置了软件包已更新到的当前版本,您可以从那里验证vue和vue-template-compiler的版本

您可以运行npm updatenpm install vue-template-compiler@2.5.16 --save-dev来获得相同的版本

运行以下命令对我有帮助

npm install vue-template-compiler@2.5.16 --save-dev

NB。用所需的正确版本替换版本号。在我的情况下,vue的版本为 2.5.16,vue-template-compiler为2.5.13 ,因此我将vue-template-compiler更新为vue的版本。

希望这对某人有帮助

Vue packages version mismatch error fix

相关问题