buildcreate-react-appwebpack-5react-scriptscraco

Problems when building React App with Craco and Webpack 5 in VSCode


I have a quite complex monorepo which I recently updated to Yarn 3. With it there where also so updates of the build specific packages like webpack, react-scripts and @craco.craco.

However, I have managed to get it all working but since recently, I get random

The "path" argument must be of type string. Received an instance of Buffer

errors, when running eg. yarn workspace @apps/app1 build. I have noticed that reloading the window in VSCode a couple of times, solves the issue.

What could be the cause of this error? Does anyone else experience similar issues?

Thanks! 🙌

Package versions

Solution

  • Found a solution

    I'm now using the Provide Plugin and set

    plugins: [
      new ProvidePlugin({ process: "process/browser.js" }),
    ]
    

    in the webpack.config section.

    Note the .js! This was getting rid of the error.