Module not found: Error: Can’t resolve ‘util’ in webpack

The main problem is with Webpack 5. It doesn’t preload the polyfill of Node.js. I see that this issue can help you. https://github.com/webpack/webpack/issues/11282

To solve it: npm install util, and add it into webpack.config.js:

module.exports = {
  // ...
  resolve: {
      fallback: {
        util: require.resolve("util/")
      }
  }
  // ...
};

Leave a Comment