开玩笑的错误,需要Babel“ ^ 7.0.0-0”,但已加载“ 6.26.3”

时间:2018-11-15 10:18:27

标签: javascript reactjs jestjs

我想运行我的jest测试,但总是在下面看到错误消息,如何才能使我的笑话测试运行?

●测试套件无法运行     需要Babel“ ^ 7.0.0-0”,但已加载“ 6.26.3”。如果您确定拥有@ babel / core的兼容版本,则可能是您的构建过程中正在加载错误的版本。检查此错误的堆栈跟踪,以查找第一个未提及“ @ babel / core”或“ babel-core”的条目,以了解正在调用的Babel。       在throwVersionError(node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)

我已经按照这里的指示进行了操作,但是仍然没有喜悦。

https://jestjs.io/docs/en/getting-started.html#using-babel

我的package.json:

{
    "name": "rgcalendar",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest",
        "test:watch": "npm test -- --watch"
    },
    "jest": {
        "preset": "react-native"
    },
    "dependencies": {
        "fsevents": "^1.2.4",
        "googleapi": "^1.0.2",
        "jest-cli": "^23.6.0",
        "moment": "^2.22.2",
        "native-base": "^2.8.1",
        "node-google-calendar": "^1.1.1",
        "prettier": "^1.13.7",
        "prop-types": "^15.6.2",
        "react": "16.3.1",
        "react-dom": "^16.5.0",
        "react-native": "^0.57.4",
        "react-native-autoreheight-webview": "^1.1.1",
        "react-native-calendars": "^1.20.0",
        "react-native-events-calendar": "^1.0.8",
        "react-native-fontawesome": "^5.7.0",
        "react-native-google-signin": "^1.0.0-rc6",
        "react-native-iphone-x-helper": "^1.0.3",
        "react-native-responsive-fontsize": "^0.1.2",
        "react-native-responsive-image": "^2.3.1",
        "react-native-vector-icons": "^4.6.0",
        "react-navigation": "^2.5.5",
        "react-navigation-redux-helpers": "^2.0.2",
        "react-redux": "^5.0.7",
        "redux": "^4.0.0",
        "redux-logger": "^3.0.6",
        "redux-thunk": "^2.3.0",
        "watchman": "^1.0.0"
    },
    "devDependencies": {
        "@babel/cli": "^7.0.0-beta.49",
        "@babel/core": "^7.1.6",
        "@babel/plugin-proposal-class-properties": "^7.0.0-beta.49",
        "@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.49",
        "@babel/preset-env": "^7.0.0-beta.49",
        "@babel/preset-flow": "^7.0.0-beta.49",
        "@babel/preset-react": "^7.0.0-beta.49",
        "babel-core": "^7.0.0-bridge.0",
        "babel-eslint": "8.2.3",
        "babel-jest": "^23.6.0",
        "babel-loader": "^8.0.0-beta",
        "babel-plugin-module-resolver": "^3.1.1",
        "enzyme-adapter-react-16": "^1.5.0",
        "eslint": "^5.0.1",
        "jest": "23.2.0",
        "jest-enzyme": "^6.0.4",
        "react-native-mock": "^0.3.1",
        "react-test-renderer": "16.3.1",
        "regenerator-runtime": "^0.12.1"
    }
}

babelrc:

{
  "presets": ["env", "react"],
  "plugins": [
    "@babel/plugin-proposal-optional-chaining",
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-syntax-dynamic-import"
  ]
}

1 个答案:

答案 0 :(得分:0)

我有同样的问题。升级到jest@24.0.0对我有用。