question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Reactions:33
  • Comments:37 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
tddcommented, Sep 10, 2018

The rimraf hack is fugly. I’m teaching a React / Redux / Jest class next week and having this postinstall script in my demo app’s package.json makes me want to take a shower.

Please, please Jest team, fix this ASAP!

9reactions
jaywcjlovecommented, Sep 1, 2018

This will be a good solution

sudo npm install babel-core@7.0.0-bridge.0 --save-dev

Run your tests again. This worked for me locally

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found