Bruno Brs
Bruno Brs

Reputation: 693

VueJS and Jest : Cannot find module 'babel-core'

I'm trying to use Jest with VueJS, however I'm getting Cannot find module 'babel-core' at Object.<anonymous> (node_modules/vue-jest/lib/compilers/babel-compiler.js:1:15).

The only way I could fix this was adding

"@babel/core": "^7.7.5",
"babel-core": "^7.0.0-beta.47",

Then test pass, but I do not want to keep the 'beta' version in my package.json, and it is weird to have @babel/core and babel-core together, knowing they are the same package in different versions.

I see the error seems to be in Vue-Jest, but it is already in last version.

Below is my current package.json that breaks (without "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"
  }

Any help would be appreciated.

Upvotes: 1

Views: 1504

Answers (1)

Zaan Chi
Zaan Chi

Reputation: 251

just use babel-bridge . from github issue

npm install babel-core@^7.0.0-bridge.0 --save-dev

Upvotes: 5

Related Questions