1

I am working on a react application where several peices of text can be shared on twitter using a button. This button would utilise the twitter api v2 so i installed the twitter-api-v2 npm package and made an object as shown here:

const { TwitterApi } = require("twitter-api-v2");

But I am getting the same errors as seen in this question: How to Polyfill node core modules in webpack 5 (I have also tried other twitter api clients' npm packages and they all result in such errors or more even) Except mine are for the packages: crypto, https, zlib and the final 2 errors are of "can't resolve fs"

I have tried the method of creating a webpack.config.js in the root of the project and adding the following code and installing the packages (as the error messages suggest) but it did not help. My webpack.config.js:

module.exports = {
  resolve: {
    fallback: {
      crypto: require.resolve("crypto-browserify"),
      https: require.resolve("https-browserify"),
      zlib: require.resolve("browserify-zlib"),
      fs: false,
    },
  },
};

Are there other solutions i can follow or is there another way for me to tweet a thread of some pieces of texts? Thanks in advance!

minz
  • 11
  • 1

0 Answers0