bitshares / bitsharesjs

JavaScript tools for BitShares Encryption and Serialization
https://bitsharesjs.bitshares.org/
MIT License
96 stars 148 forks source link

Cannot be used in "react native", will appear ”Unable to resolve module `stream`” and “can't find variable Buffer” #18

Open XJH0415 opened 6 years ago

XJH0415 commented 6 years ago

I'm working on a phone app to make "bitshares" available on the phone, but when I execute "npm install bitsharesjs," the program crashes every time I use "import {PublicKey} from / bitbitshares / s / es'".I think it may be that the "react native" running environment is inconsistent with the browser, resulting in incompatibility, which is my personal view, I hope the author can answer my question, thank you very much.

lesharadkovich commented 5 years ago

Any update here?

Momtntu commented 5 years ago

@XJH0415 Same Question as @lesharadkovich 's.

CSeanXu commented 5 years ago

@XJH0415 @lesharadkovich

The reason:

Buffer is a core node module which bitsharesjs depends on.

Solution:

npm install rn-nodeify

./node_modules/.bin/rn-nodeify --install --hack

Reference:

  1. https://github.com/bitcoinjs/bitcoinjs-lib/issues/559
  2. https://github.com/tradle/rn-nodeify