walletconnect-monorepo: Buffer is not defined error with CRA
The standalone client will throw this error with CRA and package "react-scripts": "^5.0.0":

The reason is that Webpack 5 and CRA v5 don’t add fallbacks for nodejs modules any more.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 13
- Comments: 25 (1 by maintainers)
Personally, I think that the documentation should not state that the package is compatible with browser, if it depends on modules only available on nodeJS. The browser version should include anything necessary to run out of the box, imho.
Just found a dirty workaround similar to the one posted by @ynunezaguirre Not using Craco but react-app-rewired.
Still on webpack 5.x Added a
config-overrides.jsin the root:And
npm install processThen updated the scripts part of
package.jsonThis works fine with me for now. I can use the client and pop the QR modal.
This worked for me.
Thanks @hanahem, also got it to work now. I had to additionally install util and add it to the config
npm install utilThis is just terrible imo, I spent an ENTIRE day fumbling around, exploring solutions, because of incompatible packages.
No
On Fri, Jan 13, 2023, 5:34 AM vanes @.***> wrote:
For now i haven’t found another workaround to make it run 😕
There is a plugin node-polyfill-webpack-plugin that maybe can help you , but doesn’t work for me with all modules missing.
Slight change (needs to be nested in the webpack property) to get this working with CRACO, and CRA 5.0.1
Here is a solution from coinbase https://docs.cloud.coinbase.com/wallet-sdk/docs/web3-react#a-nametroubleshootingatroubleshooting
Yeah I wish there was a solution for this. I’m on Redwoodjs.
I was able to make it run by downgrading
react-scriptsversion to4.0.3but I don’t think it’s the best solution. This should be fixed ASAP @pedrouid@esbuild-plugins/node-globals-polyfill was able to help me out with
global is not definedandBuffer is not definedhere is related comment https://github.com/plouc/nivo/issues/1455#issuecomment-1041830487craco config didn’t work for me initially until I installed buffer as a dev dependency and did ->
buffer: require.resolve('buffer/')missing / at the end of buffer.
from the docs:
I ran into the same issue with a lot of modules missing when using the last version of CRA a few days ago, it uses webpack 5.x, that has remove some node modules, Buffer is one them, a solution for me was to use Craco to config the webpack without ejecting. https://github.com/gsoft-inc/craco.