bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.68k stars 2.1k forks source link

buffer is not defined #1952

Closed NORAVemp closed 1 year ago

NORAVemp commented 1 year ago

xxxx/bitcoinjs-lib/src/script_signature.js buffer is not defined what happened

Eoous commented 1 year ago

maybe you need to install package buffer

haotian-engineer commented 1 year ago

I am getting this error when I install buffer

ERROR Buffer is not defined ReferenceError: Buffer is not defined at ./node_modules/tiny-secp256k1/rfc6979.js (http://localhost:3000/static/js/bundle.js:75088:14) at options.factory (http://localhost:3000/static/js/bundle.js:80970:31) at webpack_require__ (http://localhost:3000/static/js/bundle.js:80393:33) at fn (http://localhost:3000/static/js/bundle.js:80627:21) at ./node_modules/tiny-secp256k1/js.js (http://localhost:3000/static/js/bundle.js:74841:32) at options.factory (http://localhost:3000/static/js/bundle.js:80970:31) at webpack_require__ (http://localhost:3000/static/js/bundle.js:80393:33) at fn (http://localhost:3000/static/js/bundle.js:80627:21) at ./node_modules/bitcoinjs-lib/src/script.js (http://localhost:3000/static/js/bundle.js:17171:13) at options.factory (http://localhost:3000/static/js/bundle.js:80970:31)

Eoous commented 1 year ago

Looks like that it's a problem with wasm.

junderw commented 1 year ago

./node_modules/tiny-secp256k1/js.js

js.js file is from a pre-WASM version.

webpack doesn't automatically include Buffers anymore, you need to add a plugin to your config or create a polyfill.

Here's the first google search result for webpack buffer is not defined:

https://stackoverflow.com/a/68723223/3074620