bitcoinjs / bip39

JavaScript implementation of Bitcoin BIP39: Mnemonic code for generating deterministic keys
ISC License
1.11k stars 447 forks source link

Electron + angular : how to unit test? #179

Closed Lempkin closed 2 years ago

Lempkin commented 2 years ago

Hi,

I'm new to electron and bip39. I use this lib in a part of my app. I try to write some unit tests but when I run them I have this error :

ReferenceError: Buffer is not defined
            at Object.entropyToMnemonic (node_modules/bip39/src/index.js:109:1)

To be able to run unit tests I had to add :

  "browser": {
    "stream": false
  }

in my package.json, don't know if this is related to the problem.

Any tips?

junderw commented 2 years ago

You will get an answer quicker if you ask someone more knowledgeable with Electron.

This is not an issue with bip39, so I will be closing this. But anyone with an answer can reply.

scottwilson312 commented 2 years ago

Lempkin, what was your solution? I am having the same issue. I imagine it's something with my janky react build and webpack 5 being a disaster

scottwilson312 commented 2 years ago

In case anyone else comes across this, I lifted a solution from #29

Put this before you require bip39

global.Buffer = global.Buffer || require('buffer').Buffer;