Skip to content

Adding @babel/preset-env cause error  #2722

Closed
@marialovesbeans

Description

In my case, I'm trying to add Jest for unit testing. Jest needs to transpile the unit test code to ES5 before running it, because there're some ESNext syntax node.js does not understand, such as nullish assignment operator ?=.

However, I'm sure there're tons of other scenarios adding @babel/preset-env is necessary, so it's impactful to have this bug fixed.

Step 1) yarn add @babel/preset-env

Step 2) Add to package.json:

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

Result:
Launch website at http://localhost:3000, the webpage crashes, logging error in the browser: Uncaught SyntaxError: The requested module '/src/App.jsx' does not provide an export named 'default'

Why does adding this cause such an error? How can I fix this?

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