This question has already been asked but has never received a clear answer. Plus, the questions are old and in the blockchain space, a one-year old question is obsolete. This question is for React Native and version 0.51 and web3 version 1.0-beta
Hi,
I am trying to create a React Native application that uses web3js but I am unable to actually import it. The error is pretty obvious but I don't know how to solve it.
attempted to import the Node standard library module "crypto". It failed because React Native does not include the Node standard library.
Is the error due to Expo? Should I eject? Have anyone actually solved this?
Thanks,
Dario
Best Answer
There is some documentation about React Native that will help you understand why some packages are not possible to be included into React Native applications.
That said, you can try to include the dist files instead of the package. When you include the package via Nodejs, it will be compiled (if it's required) and possibly use some Node standard libraries.
You can find the web3 dist here, and since it's pure JavaScript (that will run in the browser), it should work also in React Native, according to this page.