Space-ID / sidjs

Javascript bindings for the Ethereum Name Service
2 stars 6 forks source link

Package makes dApp crash with "Buffer is not defined" error #22

Open BenAzlay opened 1 year ago

BenAzlay commented 1 year ago

I installed the package and now, my dApp crashes when it launches with this error in the console:

Uncaught ReferenceError: Buffer is not defined
    at ./node_modules/crypto-addr-codec/dist/index.js (index.js:1:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/@siddomains/address-encoder/lib/index.module.js (refType.js:3:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/@siddomains/sidjs/dist/index.js (index.js:37:1)
    at options.factory (react refresh:6:1)

Looking at the code in /crypto-addr-codec/dist/index.js it seems that indeed Buffer is never initialized, though n is initialized with the safe-buffer library. I attempted to replace all mentions of single Buffer with n.Buffer but still have the same error.

kevin-222 commented 1 year ago

@BenAzlay which module bundler you use in your project?