question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] 5.0 Failed to compile with create-react-app

See original GitHub issue
Failed to compile.

./node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs
Can't import the named export 'Children' from non EcmaScript module (only default export is available)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:66
  • Comments:45 (1 by maintainers)

github_iconTop GitHub Comments

77reactions
jafincommented, Nov 1, 2021

@justrealmilk I added the following to craco.config.js and it appears to work.

module.exports = {
  webpack: {
        configure: {
            module: {
                rules: [
                    {
                        type: 'javascript/auto',
                        test: /\.mjs$/,
                        include: /node_modules/,
                    },
                ],
            },
        },
    },
}
24reactions
github-user001commented, Nov 12, 2021

I’m using NextJS fwiw and fixed the error by following @j-borg’s link and just wanted to make what the solution was explicit because webpack gives me nightmares and I feel like any time I’m fortunate enough to happen across a tip that works, I am eternally grateful.

In my project, I’ve got a .storybook directory at the root.

Within that directory, I have a file at .storybook/main.js. I just added the entry for the webpackFinal property of that file, so now it looks like so (the other stuff was already there)

module.exports = {
  stories: [
    "../stories/**/*.stories.mdx",
    "../stories/**/*.stories.@(js|jsx|ts|tsx)",
  ],
  addons: ["@storybook/addon-links", "@storybook/addon-essentials"],

  /// BELOW THIS WAS ADDED

  webpackFinal: async (config, { configType }) => {
    // `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
    // You can change the configuration based on that.
    // 'PRODUCTION' is used when building the static version of storybook.

    // Make whatever fine-grained changes you need
    config.module.rules.push({
      type: "javascript/auto",
      test: /\.mjs$/,
      include: /node_modules/,
    });

    // Return the altered config
    return config;
  },
};

  /// ABOVE THIS WAS ADDED

Read more comments on GitHub >

github_iconTop Results From Across the Web

My create-react-app is failing to compile due to ESLint error
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder. 2. Delete node_modules in your project folder. 3.
Read more >
Fix Error We no longer support global installation of ... - YouTube
Fix ErrorYou are running create - react - app 4.0.3 which is behind the latest release 5.0.0We no longer support global installation of...
Read more >
CRA 5.0.0 breaks build : r/reactjs - Reddit
Steps to reproduce · Open package.json and verify that react-scripts is version 5.0.0 · Open the App.test.tsx file and introduce any syntax error....
Read more >
Webpack 5 errors | ImmutableX Documentation
The reason for this error is that create-react-app uses a version of webpack greater than 5, which, unlike versions < 5, does not...
Read more >
How to fix build failures with `create-react-app` in production
The build script bootstrapped by create-react-app performs some validation of your code. When most of this validation fails, create-react-app ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found