React-Native with web3

Encounter error after install web 3@0.20.5

Error message :

web3 import causes unable to resolve module `crypto` from /node_modules/bignumber.js/bignumber.js error.

Image for post
Image for post

Solution :

Fixed: https://github.com/ethereum/web3.js/issues/576

Edit The Following File

/node_modules/bignumber.js/bignumber.js

edit as follows:

-if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
+if ( !crypto ) try { crypto = require('crypto-js'); } catch (e) {}

Web3 Version: 0.20.5

Import in respective file

var Web3 = require('web3'); or import { default as Web3 } from 'web3';

Written by

撰寫任何事情,O型水瓶混魔羯,咖啡愛好者,Full stack/blockchain developer,Founder of Blockchain&Dapps meetup and DeFi-Decentralized-Finance-SG meetup,Udemy teacher。

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store