Babel 7 setup 'was loaded with "6.26.3"'
See original GitHub issue🐛 Bug Report
The setup suggested in the documentation doesn’t seem to work and triggers the following error message:
$ jest
FAIL ./hi.test.js
● Test suite failed to run
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. (While processing preset: "/Users/verekia/Local/Code/minimal-jest-babel-7/node_modules/@babel/preset-env/lib/index.js")
at throwVersionError (node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
at Array.map (<anonymous>)
(inline): 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. (While processing preset: “/Users/verekia/Local/Code/minimal-jest-babel-7/node_modules/@babel/preset-env/lib/index.js”)
To Reproduce
The package.json
used is the following:
{
"name": "minimal-jest-babel-7",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "babel-node consumer.js",
"test": "jest"
},
"babel": {
"presets": [
"@babel/preset-env"
]
},
"devDependencies": {
"@babel/core": "^7.0.0-beta.52",
"@babel/node": "^7.0.0-beta.52",
"@babel/preset-env": "^7.0.0-beta.52",
"babel-core": "^7.0.0-0",
"jest": "^23.3.0"
}
}
Expected behavior
Running jest
should be able to run the test, which includes an import
statement. The babel-node
command of the minimal repo executes the import successfully.
Link to repl or repo (highly encouraged)
Here is a minimal repo: https://github.com/verekia/minimal-jest-babel-7
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 10.1.0 - /usr/local/bin/node
Yarn: 1.7.0 - ~/.yarn/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
npmPackages:
jest: ^23.3.0 => 23.3.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:22 (1 by maintainers)
Top GitHub Comments
The docs says to install
babel-jest 'babel-core@^7.0.0-0' @babel/core regenerator-runtime
(https://jestjs.io/docs/en/getting-started#using-babel). Doing that (addingbabel-jest
) makes your reproduction pass.(note that regenerator runtime is not needed, I honestly don’t remember in which cases it is)
I fix this problem with them.