Bru*_* BL 1 vue.js jestjs babeljs vuejs2
我正在尝试将 Jest 与 VueJS 一起使用,但是我得到了Cannot find module 'babel-core' at Object.<anonymous> (node_modules/vue-jest/lib/compilers/babel-compiler.js:1:15).
我解决这个问题的唯一方法是添加
"@babel/core": "^7.7.5",
"babel-core": "^7.0.0-beta.47",
Run Code Online (Sandbox Code Playgroud)
然后测试通过,但我不想将“beta”版本保留在我的 package.json 中,并且将@babel/core和放在babel-core一起很奇怪,因为知道它们是不同版本中的相同包。
我看到错误似乎是在 Vue-Jest 中,但它已经在上一个版本中了。
下面是我package.json断掉的电流(没有"babel-core": "^7.0.0-beta.47")
"dependencies": {
"@vue/babel-preset-app": "^3.12.1",
"axios": "^0.19.0",
"chai": "^4.2.0",
"date-fns": "^1.30.1",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"register-service-worker": "^1.5.2",
"v-click-outside": "^2.1.5",
"vue": "^2.6.10",
"vue-alertify": "^1.1.0",
"vue-body-class": "^2.0.0-beta.2",
"vue-clipboard2": "^0.3.1",
"vue-mq": "^0.1.3",
"vue-multiselect": "^2.1.6",
"vue-recaptcha-v3": "^1.8.0",
"vue-router": "^3.1.3",
"vue-the-mask": "^0.11.1",
"vuelidate": "^0.7.4",
"vuex": "^3.1.2",
"vuex-persist": "^2.2.0"
},
"devDependencies": {
"@babel/core": "^7.7.5",
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
"@babel/polyfill": "^7.7.0",
"@babel/preset-env": "^7.7.5",
"@vue/cli-plugin-babel": "^3.12.1",
"@vue/cli-plugin-eslint": "^3.12.1",
"@vue/cli-plugin-pwa": "^3.12.1",
"@vue/cli-service": "^3.12.1",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.30",
"babel-eslint": "^10.0.3",
"copy-webpack-plugin": "^5.0.5",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.2.3",
"eslint-plugin-vue-libs": "^3.0.2",
"jest": "^24.9.0",
"vue-jest": "^3.0.5",
"vue-svg-loader": "^0.12.0",
"vue-template-compiler": "^2.6.10"
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激。
只需使用babel-bridge。来自github问题
npm install babel-core@^7.0.0-bridge.0 --save-dev
Run Code Online (Sandbox Code Playgroud)