我已经将我的应用程序迁移到Babel7测试版,除了测试之外,一切似乎都正常。我想我已经读了所有的东西,但是我仍然有这个错误:
Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely
您的生成过程中的某些内容加载了错误的版本。
检查此错误的堆栈跟踪以查找第一个条目
这并没有提到“@babel/core”或“babel core”来看看什么是
打电话给巴贝尔。
at throwVersionError (node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
at Object.assertVersion (node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
at _default (node_modules/@babel/plugin-proposal-class-properties/lib/index.js:81:7)
at node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at Array.map (<anonymous>)
测试套件:8个失败,共8个
巴贝尔
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-flow"
],
"plugins": [
["module-resolver", {
"alias": {
"static": "./static",
"common": "./src/common",
"data": "./src/data"
}
}],
["styled-jsx/babel", { "plugins": ["styled-jsx-plugin-sass"] }],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import"
]
}
开发依赖
"devDependencies": {
"@babel/cli": "^7.0.0-beta.49",
"@babel/core": "^7.0.0-beta.49",
"@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-0",
"babel-eslint": "8.2.3",
"babel-loader": "^8.0.0-beta",
"babel-plugin-module-resolver": "^3.1.1",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
...
jest.config.js网站
module.exports = {
rootDir: '<rootDir>/../../',
collectCoverageFrom: ['src/**/*.(jsx|js)'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/tests/fileMock.js',
},
setupTestFrameworkScriptFile: '<rootDir>/tests/setupTests.js',
};
我用命令运行它:
"test": "jest --config tests/jest.config.js",