-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requires Babel "^7.0.0-0", but was loaded with "6.26.3". #6913
Comments
Strange. I got the exact same error due to me removing "devDependencies": {
"@babel/core": "^7.0.0",
"babel-core": "7.0.0-bridge.0"
} Are you using |
I think this should work, your config looks correct... Mind setting up a repo showing the error? |
@jorgegonzalez same here in the project I'm working on Since I've updated to babel 8 (
And if I run
|
I was able to get rid of this error by copying I did a simple test a minute ago to see if updating
This will copy your 7.0.0 version into the
|
@matthamil That did it. Thanks! |
@matteofigus that won't work for babel 8 as all babel modules for this version are installed at |
My personal temporary solution is adding a Note: I am using Yarn. |
A solution for Yarn is to add a resolutions field to "resolutions": {
"babel-core": "7.0.0-bridge.0"
} And then run |
@herodrigues good point, I updated the PR to reflect the namespaced @babel/core: https://github.com/facebook/jest/pull/6926/files#diff-42f440414578ffb55a0c454ba79a0d5b |
This will be a good solution sudo npm install [email protected] --save-dev Run your tests again. This worked for me locally |
What's the status on this issue? This is preventing me from updating my project to babel 7. A solution that only works for yarn users isn't a solution. |
@g-plane's solution worked for me..
and add a postinstall npm script with |
The Please, please Jest team, fix this ASAP! |
A new minor version (23.6.0) was just released, but
|
What's infuriating is all these docs mentioning 7.0.0-0 which is a
version that DOES NOT EXIST. It does resolve to 7.0.0.bridge-0, but not
in Jest's context due to their local use of 6 in runtime and config.
On Mon, Sep 10, 2018, at 18:09, Herinson Rodrigues wrote:
They've just released a new minor version (23.6.0), but jest still
depends on ***@***.***
$ npm ls babel-core └─┬ ***@***.*** └─┬ ***@***.*** └─┬ jest-
***@***.*** └── ***@***.***
npm WARN ***@***.*** requires a peer of babel-core@^6.0.0 || ^7.0.0-
0 but none is installed. You must install peer dependencies yourself.
> — You are receiving this because you commented. Reply to this email
directly, view it on GitHub[1], or mute the thread[2].
--
Christophe Porteneuve
[email protected]
Links:
1. #6913 (comment)
2. https://github.com/notifications/unsubscribe-auth/AAAOqPcSn3gMoXWyNTYGFECR1-JiG4z5ks5uZo7FgaJpZM4WRvbY
|
It looks like this is the PR they're working on to implement this: |
Again, Jest works perfectly fine with Babel 7. It things are loaded incorrectly it's an issue with configuration. I've opened up a PR adding an example to Jest's code base using babel 7: #6983 |
Thank you, @SimenB. Your example helped me to get Jest up and running. For others wondering, I needed to explicitly add My 'use strict'
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-flow'],
plugins: [
// adding this one solved the issue
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
],
} |
That seems odd, that plugin should be part of the env preset already... Anyways, this issue is about the Awesome you got it to work, though! |
@SimenB I have already installed the bridge package for Babel 7, that does not fix the error unless I use yarn and I set up a |
@DBosley yeah, it still depends on I didn't have |
It doesn't matter that Make sure to use |
(I should say it's hard to deal with this issue, I had the joy to fix it three times and still I'm not sure what I've done to make the error to go away 😄) |
I will also add that this has been a little more difficult than "just install |
Small improvements like the above in the form of e.g. "You may have to delete your lockfile to get the correct dependency tree" is welcome as pull requests! I would think that a |
Are you telling me that on a fresh project, if we install Babel 7 and babel-core@7-bridge, then install Jest, we don't get Babel version conflicts? How is that even possible considering that, for instance, So far the only workaround I've seen that works is to manually strip the locally-installed babel-cores@6 in jest-config and jest-runtime, so they pick up the project-level v7… |
(At any rate, on any existing project, deleting package-lock may not be an option, and we do get the versioning conflict, so… seems to me fixing jest-runtime and jest-config's dependencies (to something like ">= 6" would be the better way) |
Almost, you also need to install
Yarn dedupes by default, but you could try to run |
I'll have to give it a whirl. On an existing project, the upgrade (as
per npx babel-upgrade) was faulty.
On Tue, Sep 18, 2018, at 13:24, Simen Bekkhus wrote:
> Are you telling me that on a fresh project, if we install Babel 7 and
> ***@***.***, then install Jest, we don't get Babel version
> conflicts?> Almost, you also need to install babel-jest. Then yes, you will not
get conflicts> — You are receiving this because you commented. Reply to this email
directly, view it on GitHub[1], or mute the thread[2].
--
Christophe Porteneuve
[email protected]
Links:
1. #6913 (comment)
2. https://github.com/notifications/unsubscribe-auth/AAAOqMpdulOqlJE2O4pZudRSePJaT2oNks5ucNfZgaJpZM4WRvbY
|
Starting on a fresh project using Experience on upgrading existing project though, involves fighting with remove-readd dependencies and lockfiles. |
It doesn't matter that jest internally requires its own version, we require the version you define when transpiling your code (just make sure to have the bridge package at the top level) |
@SimenB better lock this issue. People will keep coming here to complain about it even though they don't check their project configuration. |
I was able to get my project working by running |
@herodrigues good call! If people have (babel) issues with Babel 7 whilst:
feel free to open a new issue. If you fit any of the requirements above, without fulfilling all of them, also feel free to open up a new issue! |
@SimenB FYI, I've seen non-native speakers misunderstand your comment as a call to "do not use create-react-app" :-) To future readers — if you read it that way, please start again and re-read the whole comment. |
Sorry! Changed it to "not using create-react-app". Feel free to edit my comment yourself if you think it can be further clarified. Did not mean to imply you shouldn't use CRA 🙂 EDIT: Also moved it to the top so it reads more naturally |
🐛 Bug Report
I get the following message when trying to run tests. None of the solutions in the documentation or other issues work.
To Reproduce
Relevant
package.json
dependencies/config.babelrc
jestSetup.js
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
The text was updated successfully, but these errors were encountered: