Requires Babel "^7.0.0-0", but was loaded with "6.26.3".
See original GitHub issue🐛 Bug Report
I get the following message when trying to run tests. None of the solutions in the documentation or other issues work.
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.
at throwVersionError (node_modules/@babel/plugin-proposal-class-properties/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
at Object.assertVersion (node_modules/@babel/plugin-proposal-class-properties/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/plugin-proposal-class-properties/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at Array.map (<anonymous>)
To Reproduce
Relevant package.json
dependencies/config
{
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"babel-loader": "^8.0.0",
"jest": "^23.5.0",
"jest-environment-jsdom": "^23.4.0",
"jest-junit": "^3.6.0",
"jest-transform-graphql": "^2.1.0",
"regenerator-runtime": "^0.12.1"
},
"jest": {
"coveragePathIgnorePatterns": [
"node_modules",
"/*.graphql"
],
"transform": {
"\\.(gql|graphql)$": "jest-transform-graphql",
"^.+\\.js$": "babel-jest"
},
"setupFiles": [
"<rootDir>/src/jestSetup.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"testResultsProcessor": "jest-junit"
}
}
.babelrc
{
"presets": ["@babel/preset-react"],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-dynamic-import",
["@babel/plugin-proposal-decorators", { "legacy": true }]
],
"env": {
"test": {
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
}
}
jestSetup.js
import 'regenerator-runtime';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
Expected behavior
Jest runs correctly
Link to repl or repo (highly encouraged)
Please provide either a repl.it demo or a minimal repository on GitHub.
Issues without a reproduction link are likely to stall.
Run npx envinfo --preset jest
Throws the follwing error
(node:792) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null
Issue Analytics
- State:
- Created 5 years ago
- Reactions:33
- Comments:37 (7 by maintainers)
Top Results From Across the Web
Requires Babel "7.0.0-0" but was loaded with "6.26.3"
Test which version you are running with cmd babel -V. If it is not verion 7 or higher npm uninstall babel-cli -g npm...
Read more >Requires Babel “7.0.0-0” but was loaded with “6.26.3” - GitHub
In a test setup.js file, I was importing babel-register instead of @babel/register . If you feel like your dependencies are updated, ...
Read more >Requires Babel "^7.0.0-0", but was loaded with "6.26.3"
I'm facing the below build issue. Some of dependencies has babel 6 and some has babel 7. But, when a dependency requires babel...
Read more >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...
Read more >Error_ Requires Babel _^7.0.0-0_, but was loaded ... - 博客园
Error : 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, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
rimraf
hack is fugly. I’m teaching a React / Redux / Jest class next week and having thispostinstall
script in my demo app’spackage.json
makes me want to take a shower.Please, please Jest team, fix this ASAP!
This will be a good solution
Run your tests again. This worked for me locally