Ts-jest: Old babel version

Created on 24 Apr 2018  路  5Comments  路  Source: kulshekhar/ts-jest

  • Issue
    In my project, I'm using babel 7 with the following .babelrc:
{
    "presets": [
        [
            "@babel/preset-env",
            {
                "targets": {
                    "browsers": [
                        "last 2 versions",
                        "safari >= 10"
                    ]
                }
            }
        ],
        "@babel/preset-stage-2"
    ]
}

when I'm trying to run jest using ts-jest in useBabelrc mode it failed and I'm getting the following error:

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 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. (W
hile processing preset: "/path/node_modules/@babel/preset-env/lib/index.js")

I have some experience with this issue and it seems that when I'm using useBabelrc mode it use the ts-jest babel version and it's incompatible with my babel features.

I see two ways to solve it:

  • Use client project babel version.
  • Upgrade ts-jest babel version.

I will be glad to contribute one of the solutions if it's agreed.

Most helpful comment

This worked for me

  "resolutions": {
    "babel-core": "^7.0.0-bridge.0"
  },

All 5 comments

Is babel 7 still not in beta?

yea, it is.
image

In that case I don't think we should update.
I don't think it's possible to either use our bundled version of babel, unless the project already has it installed - and then use theirs. Either way this opens us up to supporting a billion different versions of babel, which I'd like to avoid.

Can you not just pin the babel version we're using, with something like this?

This worked for me

  "resolutions": {
    "babel-core": "^7.0.0-bridge.0"
  },

Closing as wontfix

Was this page helpful?
0 / 5 - 0 ratings