Buffer is not defined
See original GitHub issueweb3modal crashes when WalletConnect is a provider with the following error:
Uncaught ReferenceError: Buffer is not defined
at Object../node_modules/web3-provider-engine/node_modules/ethereumjs-util/dist/secp256k1-lib/der.js (der.js:6:1)
at Object.options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:62:1)
at Object../node_modules/web3-provider-engine/node_modules/ethereumjs-util/dist/secp256k1-adapter.js (secp256k1-adapter.js:6:1)
at Object.options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:62:1)
at Object../node_modules/web3-provider-engine/node_modules/ethereumjs-util/dist/index.js (index.js:11:1)
at Object.options.factory (react refresh:6:1)
when using create-react-app version 5.0.0.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
node.js - Uncaught ReferenceError: Buffer is not defined
Answering my own question. Two things helped to resolve the issue: Adding plugins section with ProviderPlugin into webpack.config.js.
Read more >Uncaught ReferenceError: Buffer is not defined · Issue #2248
I am facing a similar error, while trying to include graphql-ws in my app. constants.js:5 Uncaught ReferenceError: Buffer is not defined at ...
Read more >Buffer is not defined. Using Phantom Wallet ...
This is happening because the default bundler that comes with create react app(webpack 5) does not polyfill Buffer .
Read more >How to polyfill Buffer with Webpack 5 - viglucci.io
The "buffer is not defined" error is a common error that can occur when trying to use the Buffer Node.js API in an...
Read more >ReferenceError: Buffer is not defined - Questions & Help
Buffer is a global variable set by homeyscript. Now it is not defined anymore. Why do you need the script? If you think...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Glad to hear that! I ended up running into more dependency issues with the missing polyfills. If you end up down that route, there’s a solution with
react-app-rewired
package ( https://alchemy.com/blog/how-to-polyfill-node-core-modules-in-webpack-5 )I ran into the same issue when upgrading to React 18 with CRA. This is because the Node polyfills are no longer bundled with webpack. This solution worked for my app:
Install the
buffer
package:Add the following line to
index.js
:Additional reading:
https://stackoverflow.com/questions/37656592/define-global-variable-with-webpack