Skip to content

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

Open

Description

@alexmercier25

Hi. When I try to build my files, it gives me this error.

I think that's because Babel 6.23.0 is used by drupal-js-build. I was wondering if you can update the version?

Thanks

Activity

  1. tanc commented on Jan 19, 2022

    @tanc

    Also seeing this problem

  2. tanc commented on Jan 19, 2022

    @tanc

    A bit more info and a solution: In my case I have a module for Gutenberg which has scripts for building a Gutenberg block in JavaScript. The requirements for that are Babel@^7.0 but I also need to build Drupal JS in the same module. The error gets thrown due to .babelrc specifying presets. If I comment out .babelrc then no error is thrown.

    In babelrc it is possible to restrict presets and plugins to specific environments. In mine I've set the needed config to only apply in the NODE_ENV=babel7 environment:

    {
      "env": {
        "babel7": {
          "presets": ["@babel/preset-env", "@babel/preset-react"],
          "plugins": [["@babel/plugin-proposal-class-properties"]]
        }
      }
    }
    

    This way I can run my build script like this (from package.json):

    "build": "NODE_ENV=babel7 wp-scripts build",
    

    and my drupal-js-build from the command line like this:

    npx drupal-js-build
    
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions