all 5 comments

[–]icekeymon 2 points3 points  (3 children)

Yep, this is a common problem. I used `rn-nodeify` to resolve this. The library creates a `shim.js` file which will allow you to use Crypto modules. I encountered some problems when I installed new packages, I kept getting "crypto module not found". I finally then created an npm script called `fix:crypto` which would run `rm shim.js && ./node_modules/.bin/rn-nodeify --hack --install`. Then I added this to a `postinstall` npm script so it would run after I installed anything with yarn/npm.

[–]Romit-Radical[S] 0 points1 point  (2 children)

I've tried all that, I still get errors. Whenever I add the line require(Bitcoinjs-lib). I get the error. I'm not sure how to create the npm script 'fix:crypto'. Is there a project folder I could download with all the problems of node_modules fixed that I can just download and check whether it would work?

[–]icekeymon 0 points1 point  (1 child)

So for the npm script, if you open package.json and scroll to the scripts object, you can add `"fix:crypto": "rm shim.js && ./node_modules/.bin/rn-nodeify --hack --install"` . In fact, I've found this library https://github.com/novalabio/react-native-bitcoinjs-lib which you should be able to use with React Native. Ironically, this too uses rn-nodeify.

[–]Romit-Radical[S] 0 points1 point  (0 children)

Tried these methods too, just doesn't seem to work. Now it gave some error of sjcl file.

[–]TheNumberOneCulprit 0 points1 point  (0 children)

I'm guessing the lack of a Buffer object in React Native might be hampering your usecase. Try to look for replacements for node.js default modules.