Skip to content

Migrate to babel 7: Requires Babel "^7.0.0-0", but was loaded with "6.26.3" #8206

@budarin

Description

@budarin

Bug Report

Current Behavior
I've tried to move to Babel 7 on existing simple project.
When I've finished migration I've got the error:

  throw Object.assign(err, {
  ^
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.

Babel config for transformation the app is in /config/babelLoaderConfig.js
Here is link for the repository

Environment

  • Babel version(s): v7.0.0-beta.51
  • Node/npm version: Node 10.4./npm 6
  • OS: Windows 7
  • Monorepo yes
  • How you are using Babel: loader

Activity

babel-bot

babel-bot commented on Jun 21, 2018

@babel-bot
Collaborator

Hey @budarin! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

xtuc

xtuc commented on Jun 21, 2018

@xtuc
Member

I think that you're loading a plugin that uses Babel 6 which is not compatible with Babel 7.

budarin

budarin commented on Jun 21, 2018

@budarin
Author

@xtuc
What is the solution?
Move back?

ajliv

ajliv commented on Jun 21, 2018

@ajliv

@budarin try installing babel-core@7.0.0-bridge.0 alongside @babel/core and then adding this to your package.json --

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

budarin commented on Jun 21, 2018

@budarin
Author

@ajliv
I've tried but with the same error :(

loganfsmyth

loganfsmyth commented on Jun 21, 2018

@loganfsmyth
Member

As mentioned in the error itself, the stack trace is the important part here to diagnose the issue. Please include that.

budarin

budarin commented on Jun 21, 2018

@budarin
Author

Here is full log:

d:\Projects\react-bootstrap-project\node_modules\babel-core\lib\transformation\file\options\option-manager.js:180
          throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));
          ^

ReferenceError: Unknown plugin "@babel/plugin-syntax-dynamic-import" specified in "d:\\Projects\\react-bootstrap-project\\.babelrc" at 0, attempted to resolve relative to "d:\\Projects\\react-bootstrap-project"
    at d:\Projects\react-bootstrap-project\node_modules\babel-core\lib\transformation\file\options\option-manager.js:180:17
    at Array.map (<anonymous>)
    at Function.normalisePlugins (d:\Projects\react-bootstrap-project\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
    at OptionManager.mergeOptions (d:\Projects\react-bootstrap-project\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
    at OptionManager.init (d:\Projects\react-bootstrap-project\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at compile (d:\Projects\react-bootstrap-project\node_modules\babel-register\lib\node.js:103:45)
    at loader (d:\Projects\react-bootstrap-project\node_modules\babel-register\lib\node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (d:\Projects\react-bootstrap-project\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
budarin

budarin commented on Jun 21, 2018

@budarin
Author

Repo is changed (I have undo babel7 modifications to Babel 6), but you cold do checkout the head to reproduce the error

git checkout 957fc9df5dc6807c22f59ea0f65a4247532f0e70
loganfsmyth

loganfsmyth commented on Jun 21, 2018

@loganfsmyth
Member

Yeah, so you have babel-register which is Babel 6. It would be @babel/register for Babel 7.

budarin

budarin commented on Jun 21, 2018

@budarin
Author

@loganfsmyth
I have not babel-register in package.json!

    "devDependencies": {
        "@babel/cli": "^7.0.0-beta.51",
        "@babel/core": "^7.0.0-beta.51",
        "@babel/plugin-proposal-class-properties": "^7.0.0-beta.51",
        "@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.51",
        "@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.51",
        "@babel/plugin-transform-react-constant-elements": "^7.0.0-beta.51",
        "@babel/plugin-transform-react-inline-elements": "^7.0.0-beta.51",
        "@babel/plugin-transform-react-jsx-self": "^7.0.0-beta.51",
        "@babel/plugin-transform-react-jsx-source": "^7.0.0-beta.51",
        "@babel/preset-env": "^7.0.0-beta.51",
        "@babel/preset-react": "^7.0.0-beta.51",
        "babel-core": "^7.0.0-bridge.0",
        "babel-jest": "^23.0.1",
        "babel-loader": "^7.1.4",
        "babel-minify-webpack-plugin": "^0.3.1",
        "babel-plugin-external-helpers": "^6.22.0",
        "babel-plugin-lodash": "^3.3.4",
        "copy-webpack-plugin": "^4.5.1",
        "css-loader": "^0.28.11",
        "enzyme": "^3.3.0",
jsg2021

jsg2021 commented on Jun 21, 2018

@jsg2021

@budarin you have babel-core twice with different values. Try deleting the line:

"babel-core": "^6.26.3",
loganfsmyth

loganfsmyth commented on Jun 21, 2018

@loganfsmyth
Member

@budarin Since you're using a webpack.config.babel.js file, Webpack loads babel-register/@babel/register automatically, but since you don't have it in you deps you're basically accidentally relying on npm to flatten your dependencies and you're getting one by chance.

budarin

budarin commented on Jun 21, 2018

@budarin
Author

@jsg2021
I have no "babel-core": "^6.26.3", - it's error while copy from commit log - not remove removed line

budarin

budarin commented on Jun 21, 2018

@budarin
Author

@loganfsmyth
Should I manually install @babel/register to resolve the problem?

loganfsmyth

loganfsmyth commented on Jun 21, 2018

@loganfsmyth
Member

Yep!

29 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @loganfsmyth@ajliv@jsg2021@nickjuntilla@xtuc

        Issue actions

          Migrate to babel 7: Requires Babel "^7.0.0-0", but was loaded with "6.26.3" · Issue #8206 · babel/babel