首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jest错误,需要Babel“^7.0.0-0”,但加载的是“6.26.3”

Jest错误,需要Babel“^7.0.0-0”,但加载的是“6.26.3”
EN

Stack Overflow用户
提问于 2019-03-19 18:27:46
回答 1查看 1K关注 0票数 0

对于我运行的每个Jest测试套件,我都会得到这个错误:

Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.

但奇怪的是,只有当我尝试通过npm install安装软件包时,才会出现此错误。那么问题出在哪里呢?我做错了什么?附言:我不想用yarn install

这是我的paskage.json的巴别塔,jest和酶相关的部分:

代码语言:javascript
复制
{
  "devDependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.3.4",
    "@babel/plugin-proposal-class-properties": "^7.2.3",
    "@babel/plugin-proposal-decorators": "^7.2.3",
    "@babel/plugin-proposal-export-default-from": "^7.2.0",
    "@babel/plugin-proposal-export-namespace-from": "^7.2.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
    "@babel/plugin-transform-object-assign": "^7.2.0",
    "@babel/plugin-transform-runtime": "^7.2.0",
    "@babel/preset-flow": "^7.0.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "^23.6.0",
    "babel-loader": "8.0.4",
    "babel-plugin-react-docgen": "^2.0.0",
    "enzyme": "^3.8.0",
    "enzyme-adapter-react-16": "^1.7.1",
    "jest": "^23.6.0",
    "jest-enzyme": "^7.0.1",
    "jest-pnp-resolver": "1.0.1",
    "jest-resolve": "23.6.0",
  },
}
EN

回答 1

Stack Overflow用户

发布于 2019-03-21 21:50:08

Jest 23不支持@ babel /core 7。请升级到支持babel 7的Jest 24或运行

代码语言:javascript
复制
npm install --save-dev babel-core@7.0.0-bridge.0

为jest 23加载兼容版本的babel

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55238760

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档