'Don't include polyfill to React JS with Slack Bolt

I have a really simple ReactJS code that use the Slack Bolt package. When I run npm run start I have three errors :

Module not found: Error: Can't resolve 'os'

Module not found: Error: Can't resolve 'path'

Module not found: Error: Can't resolve 'querystring'

The code

  const { WebClient } = require("@slack/web-api");
  const token = process.env.SLACK_TOKEN;
  const web = new WebClient(token);
  const r = web.channels.list()
  console.log(r);

I have many information on how to solve it but none worked.

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it. If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "querystring": false }

I tried to configure weback by adding this lines to a webpack.config.js on the project's root

module.exports = {
  resolve: {
    fallback: {
      assert: false,
      crypto: false,
      http: false,
      https: false,
      os: false,
      stream: false,
      path: false,
      querystring: false,
    },
  },
};

No solutions worked. Any ideas on how to solve this issue?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source