Skip to content
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

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3" #522

Closed
rccclr opened this issue May 11, 2018 · 52 comments
Closed

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3" #522

rccclr opened this issue May 11, 2018 · 52 comments

Comments

@rccclr
Copy link

rccclr commented May 11, 2018

When
npm start
o
yarn start

Thanks

@PT-Jessica
Copy link

Please any help ? I installed updated version for babel 7 but this error displays in console while I run npm start or npm install.

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, 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: "C:\Users\japolinar\Documents\orion-github\pt-orion-rh\node_modules\@babel\preset-env\lib\index.js")

@joe-lloyd
Copy link

joe-lloyd commented May 21, 2018

@PT-Jessica try this

yarn add babel-core@7.0.0-bridge.0

it got rid of the error for me by creating a bridge that supports babel 6 & 7

src parcel-bundler/parcel#868 (comment)

@LeBenLeBen
Copy link

LeBenLeBen commented May 22, 2018

I have a similar issue on a fresh clone of the repository, here‘s more info:

ERROR in ./index.js
Module build failed: 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, 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 (/Users/leben/Sites/spectacle/node_modules/@babel/helper-plugin-utils/lib/index.js:62:11)
    at Object.assertVersion (/Users/leben/Sites/spectacle/node_modules/@babel/helper-plugin-utils/lib/index.js:11:11)
    at /Users/leben/Sites/spectacle/node_modules/@babel/plugin-proposal-object-rest-spread/lib/index.js:15:7
    at /Users/leben/Sites/spectacle/node_modules/@babel/helper-plugin-utils/lib/index.js:16:12
    at Function.memoisePluginContainer (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/options/option-manager.js:113:13)
    at Function.normalisePlugin (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/options/option-manager.js:146:32)
    at /Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
    at OptionManager.mergeOptions (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
    at OptionManager.init (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/index.js:212:65)
    at new File (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/file/index.js:135:24)
    at Pipeline.transform (/Users/leben/Sites/spectacle/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/Users/leben/Sites/spectacle/node_modules/babel-loader/lib/index.js:50:20)
    at Object.module.exports (/Users/leben/Sites/spectacle/node_modules/babel-loader/lib/index.js:173:20)
 @ multi (webpack)-dev-server/client?http://localhost:3000 webpack/hot/dev-server ./index

@joeLloyd tip doesn’t seem to work for me.

@kenwheeler
Copy link
Contributor

Can someone provide a repo that demonstrates this issue so that I can investigate further?

@artyomtrityak
Copy link

you can use npm install babel-loader@next if you're using webpack

@gogulanareshkw
Copy link

please help me to resolve compatibilty issue.

"dependencies": {
"@babel/core": "^7.0.0-beta.55",
"@babel/preset-env": "^7.0.0-beta.55",
"@babel/preset-react": "^7.0.0-beta.55",
"native-base": "^2.6.1",
"react": "^16.4.1",
"react-native": "^0.55.4",
"react-native-code-push": "^5.4.1",
"react-native-vector-icons": "^4.6.0",
},
"devDependencies": {
"babel-eslint": "^6.1.2",
"babel-jest": "^23.4.2",
"babel-preset-react-native": "^4.0.0",
"chai": "^3.5.0",
"eslint": "^3.5.0",
"eslint-config-airbnb": "^11.1.0",
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-jsx-a11y": "^2.2.1",
"eslint-plugin-react": "^6.2.0",
"eslint-plugin-react-native": "^2.0.0",
"jest": "17.0.0",
"jest-react-native": "17.0.0",
"mocha": "^2.5.3",
},

image

@rmc33
Copy link

rmc33 commented Aug 15, 2018

npm install --save-dev babel-loader@^8.0.0-beta

https://webpack.js.org/loaders/babel-loader/

You are using babel-core instead of @babel/core, installing babel-loader@^8.0.0-beta will use @babel/core and should fix the issue

@rayj10
Copy link

rayj10 commented Aug 16, 2018

@rmc33 tried ur solution, giving me this upon installation:

No matching version found for babel-loader@8.0.0-beta
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

any idea why?

@rmc33
Copy link

rmc33 commented Aug 16, 2018

Hi @rayj10
That is because you are using babel-loader@8.0.0-beta instead of babel-loader@^8.0.0-beta. There is no specific version 8.0.0-beta so if you wanted to reference a specific 8 version check https://www.npmjs.com/package/babel-loader, I see the latest is babel-loader@8.0.0-beta.4

@rayj10
Copy link

rayj10 commented Aug 17, 2018

@rmc33 Ah yes i see thanks for the pointers! 😄

@rmc33
Copy link

rmc33 commented Aug 17, 2018

@rayj10 no problem, as you can see babel-core changed to @babel/core at version 7 which will cause these problems if you are still using loaders, plugins or presets that use babel-core, maybe you need to keep babel-core for some time or go ahead and upgrade if they are available for @babel/core.

@peterrattew-old
Copy link

I would recommend using Babel Upgrade and let it update all your dependencies to whats needed.

@developer239
Copy link

@peterrattew thank you so much 🙂 that tool is priceless

@teclone
Copy link

teclone commented Sep 3, 2018

@PT-Jessica, @LeBenLeBen , @joeLloyd
in version 7, babel decided to implement their stuffs as scoped packages, whereby you simply replace babel- to @babel/.

Examples:
babel-register => @babel/register
babel-core => @babel/core.

if you are using babel 7, then you have to install all dependencies with the naming convention shown above. babel-eslint would be @babel/eslint, same applies to babel-jest, etc.

when referencing the packages, reference them as they are too.
e.g is shown in this babelrc below

{
    "presets": ["@babel/preset-env"]
}

Read migration article at babel website

@ccorcos
Copy link

ccorcos commented Sep 8, 2018

I think the problem has to do with Jest using an older version of Babel.

@ccorcos
Copy link

ccorcos commented Sep 8, 2018

Maybe try forcing Jest to use babel 7.

babel/babel#8206 (comment)

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

@elangosundar
Copy link

Just add "@babel/cli": "^7.0.0" into your package.json file and npm install.
It will resolve this issue.

@za-ek
Copy link

za-ek commented Sep 12, 2018

Replacing all packages like 'babel-core', 'babel-cli' etc.. with '@babel/core', '@babel/cli' solve the problem.

@brybrophy
Copy link

I just dealt with this issue after upgrading all of the packages in react-progressive-image.

The problem there was with babel-jest. The babel-jest repo has this note in it.
screen shot 2018-09-19 at 7 31 29 pm

@bhariyani
Copy link

install "@babel/core": "^7.1.0" that will fix.

@DZuz14
Copy link

DZuz14 commented Sep 25, 2018

For me it was as simple as:

"@babel/core": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",

Jest was not working until I added the bridge package below @babel/core

andreaswachowski pushed a commit to andreaswachowski/debug-react-redux-form that referenced this issue Oct 2, 2018
In addition, needed to install babel-jest and the babel-core-bridge,
since apparently Jest still depends on babel 6.x.

For example, see FormidableLabs/spectacle#522
@ruslanxdev
Copy link

I fix this problem with them.

npm i -D jest babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
// babel.config.js
'use strict';

module.exports = {
  presets: [
    '@babel/preset-env',
    '@babel/preset-react'
  ],
  plugins: [
    '@babel/plugin-transform-modules-commonjs',
    '@babel/plugin-transform-object-assign',
    '@babel/plugin-proposal-class-properties',
    '@babel/plugin-proposal-object-rest-spread'
  ]
};
// jest.config.js
'use strict';

module.exports = {
    transform: {
        '^.+\\.jsx$': 'babel-jest',
        '^.+\\.js$': 'babel-jest'
    }
};

@GTOsss
Copy link

GTOsss commented Oct 29, 2018

I have the same problem.

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3"...

I tryed install babel-core@7.0.0-bridge.0.

Package.json:

"dependencies": {
    "colors": "^1.3.2",
    "stringify-object": "^3.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.1.2",
    "@babel/plugin-transform-modules-commonjs": "^7.1.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-react": "^7.0.0",
    "babel-cli": "^6.26.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-loader": "^8.0.4",
    "cross-env": "^5.2.0",
    "webpack": "^4.23.1",
    "webpack-cli": "^3.1.2"
  }

.babelrc:

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "env": {
    "development": {
      "plugins": ["@babel/plugin-transform-modules-commonjs"]
    },
    "production": {
      "plugins": ["@babel/plugin-transform-modules-commonjs"]
    }
  }
}

@rmc33
Copy link

rmc33 commented Oct 29, 2018 via email

@rmc33
Copy link

rmc33 commented Oct 29, 2018 via email

@GTOsss
Copy link

GTOsss commented Oct 30, 2018

@rmc33 Thank you!

@teclone
Copy link

teclone commented Oct 30, 2018

I am using jest with babel 7. here is how i did it and it is working very fine, install the following packages

npm install -D @babel/core @babel/preset-env babel-jest babel-core@^7.0.0-bridge.0 regenerator-runtime

I also installed babel cli globally

npm install -g @babel/cli

setup your .babelrc.json file to use the preset like shown below

{
    "env": {
      "test": {
        "presets": [
          [
            "@babel/preset-env"
          ]
        ]
      },
      "build": {
        "presets": [
          [
            "@babel/preset-env",
            {
              "modules": false
            }
          ]
        ]
      }
    }
  }

in your test script in package.json, this is how i did it

{
    "test": "BABEL_ENV=test jest --config ./jest.config.json",
}

@ruslanxdev
Copy link

@GTOsss try rewrite .babelrc to babel.config.js ;)

@ashishdommety
Copy link

Installing babel-core@^7.0.0-bridge.0 seems to work for me -- I already had "@babel/core": "^7.1.6" installed though.
Any pointers on why just @babel-core doesn't do the trick?

@inovramadani
Copy link

inovramadani commented Nov 25, 2018

I have the same problem.

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3"...

I tryed install babel-core@7.0.0-bridge.0.

I have the same problem. My project using webpack 4 and fixed the problem with npm install babel-core@7.0.0-bridge.0 --save-dev

@SilentFlute
Copy link

hi guys, i occur this problem too, and i try many solve ways above these answers, babel-core@7.0.0-bridge.0 even upgraded babel-loader from 8.0.0 to 8.0.4, until i see @harrison Ifeanyichukwu , he mentioned @babel/register, and i realized i had babel-register, so i install @babel/register to instead it, then the problem still there, and i search babel-register, i find there is a js use it, and i change it to @babel/register, so that's it, the problem is solved!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@SilentFlute
Copy link

@harrison-ifeanyichukwu i am sorry😂😂

@bruevin-paul
Copy link

bruevin-paul commented Dec 25, 2018

"dependencies": {
"express": "^4.16.4",
"mongodb": "^3.1.10",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-2": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"eslint": "^5.11.0",
"eslint-plugin-react": "^7.11.1",
"nodemon": "^1.18.9",
"webpack": "^4.28.2",
"webpack-cli": "^3.1.2"
}

Getting same error pls assist me to fix
struck with this error for couple of days

@kevinsimper
Copy link

I made a working example of babel-jest after an hour of errors, so if any poor soul lands on this issue: https://github.com/kevinsimper/babel-jest-example

@igbominadeveloper
Copy link

hi guys, i occur this problem too, and i try many solve ways above these answers, babel-core@7.0.0-bridge.0 even upgraded babel-loader from 8.0.0 to 8.0.4, until i see @harrison Ifeanyichukwu , he mentioned @babel/register, and i realized i had babel-register, so i install @babel/register to instead it, then the problem still there, and i search babel-register, i find there is a js use it, and i change it to @babel/register, so that's it, the problem is solved!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Did you edit your node_modules file?

@SilentFlute
Copy link

hi guys, i occur this problem too, and i try many solve ways above these answers, babel-core@7.0.0-bridge.0 even upgraded babel-loader from 8.0.0 to 8.0.4, until i see @harrison Ifeanyichukwu , he mentioned @babel/register, and i realized i had babel-register, so i install @babel/register to instead it, then the problem still there, and i search babel-register, i find there is a js use it, and i change it to @babel/register, so that's it, the problem is solved!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Did you edit your node_modules file?

Nope!!!! Only the webpack config files, and now, I used a scaffold, it solved all the bundle and compile things, that I can focus on programming

@ghost
Copy link

ghost commented Jan 9, 2019

I searched on the internet and tried different solutions (attempts). Nothing worked. Among others I also removed package.json and node_modules. What worked is to uninstall babel-jest with having jest as the only modules parsing my tests.
This confuses me because I thought the jest module's responsibility is only parsing test (\(...).+\.test.js\) files. Or does babel the job? Would be a pleasure to enlighten me.
PS: Of course I tried the normal and officially documented way of installation.

{
  (...)
  "devDependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.2.2",
    "@babel/preset-env": "^7.2.3",
    "@babel/preset-typescript": "^7.1.0",
    "@types/jest": "^23.3.12",
    "babel-core": "^7.0.0-bridge.0",
    "jest": "^23.6.0",
    "regenerator-runtime": "^0.13.1",
    "tslint": "^5.12.0",
    "typescript": "^3.2.2"
  },
  "dependencies": {}
}

yukihirop added a commit to yukihirop/octotag-for-stars-refactor that referenced this issue Jan 14, 2019
「babel-core: "7.0.0-bridge.0"」はこのエラーを回避するため

```
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.
```

[reference]
FormidableLabs/spectacle#522 (comment)
@blairbodnar
Copy link

I made a working example of babel-jest after an hour of errors, so if any poor soul lands on this issue: https://github.com/kevinsimper/babel-jest-example

Thanks for this @kevinsimper !

@meanmachine22
Copy link

{
"name": "babel_comp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"build": "babel src --out-dir dist"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.0",
"@babel/node": "^7.2.2",
"@babel/preset-env": "^7.4.1",
"nodemon": "^1.18.10"
}
}

.babelrc
{
"presets": [ "@babel/preset-env"]
}

Still getting the same
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, 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.

This is the error when I write a sample ES6 component and try to compile babel to ES5 with babel server/index.js -o server/index_comp.js

Is this problem still occurring or is it fixed??

@ebrillhart
Copy link
Contributor

@meanmachine22 if you're using the latest version of Spectacle, the expectation is that this should be fixed!

@GavinMoreYoung
Copy link

maybe you could install global babel-cli, you can try command : npm uninstall -g babel-cli babel-node.you need install @babel/cli and @babel/node.
OR
you can uninstall node and remove npm file in C:\Users\Administrator\AppData\Roaming
i hope i can help you.good luck

@KKica
Copy link

KKica commented Jul 18, 2019

If you are using babelify 7.3, update to 9.0
See my answer on stackoverflow

@PukkyCoopie
Copy link

you can use npm install babel-loader@next if you're using webpack

OMG BRO, YOU SAVED MY DAY!

@stevendaye
Copy link

Very bizarre. Me rather, I npm uninstall babel-core: --save-dev, and it works like a charm.

PS: I mean the package babel-core: ^7.0.0-bridge.0"

@97thjingba
Copy link

If it does not work still when you intall babel-core ^7.0.0-bridge.0".
you can try change you .babelrc to babel.config.js
it work for me

@maggiew61
Copy link

maggiew61 commented Feb 5, 2020

� �I tried all the methods here until my colleague pointed out that I didn't remove another babel v6 package, and so it was still there in package.json. I removed it and installed a few babel v7 packages and it finally worked.

this is my working .babelrc
{
"presets": [
[
"@babel/preset-env"
],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
}

this is a part of my working package.json
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.8.4",
"@babel/node": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^25.1.0",
"jest": "^25.1.0",
"nodemon": "^2.0.2",
"standard": "^14.3.1"
},
"dependencies": {
"babel-upgrade": "^1.0.1",
"express": "^4.17.1",
"iso-redux": "^1.3.12",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.1.3",
"redux": "^4.0.5",
"redux-actions": "^2.6.5"
}

the key working factor for me was that I didn't remove all babel v6 related packages and so it was still conflicting with the new babel v7 stuff.

I hope it will help out someone.

@LiMengyang990726
Copy link

� �I tried all the methods here until my colleague pointed out that I didn't remove another babel v6 package, and so it was still there in package.json. I removed it and installed a few babel v7 packages and it finally worked.

this is my working .babelrc
{
"presets": [
[
"@babel/preset-env"
],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
}

this is a part of my working package.json
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.8.4",
"@babel/node": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^25.1.0",
"jest": "^25.1.0",
"nodemon": "^2.0.2",
"standard": "^14.3.1"
},
"dependencies": {
"babel-upgrade": "^1.0.1",
"express": "^4.17.1",
"iso-redux": "^1.3.12",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.1.3",
"redux": "^4.0.5",
"redux-actions": "^2.6.5"
}

the key working factor for me was that I didn't remove all babel v6 related packages and so it was still conflicting with the new babel v7 stuff.

I hope it will help out someone.

Hi do you know how to remove all babel v6 related packages?

@maggiew61
Copy link

maggiew61 commented Feb 7, 2020

hi @LiMengyang990726 check out this stackoverflow response regarding to package changes.

Most of the packages in Babel has been renamed to follow the pattern @babel/PACKAGE_NAME

I removed all 3 babel packages that didn't have the @ prefix, which meant they are older versions and are v6 packages. hope it helps

@LiMengyang990726
Copy link

hi @LiMengyang990726 check out this stackoverflow response regarding to package changes.

Most of the packages in Babel has been renamed to follow the pattern @babel/PACKAGE_NAME

I removed all 3 babel packages that didn't have the @ prefix, which meant they are older versions and are v6 packages. hope it helps

Thank you! I have solved it by changing all the babel related packages in "x-x" into "@x/x"

@vintagexav
Copy link

Replacing all packages like 'babel-core', 'babel-cli' etc.. with '@babel/core', '@babel/cli' solve the problem.

You deserve a medal <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests