react-native-crypto: TypeError: undefined is not a constructor (evaluating 'new brorand.Rand()')
I am using react-native-crypto with rn-nodeify. but got following error
Requiring module "react-native-crypto/index.js", which threw an exception: TypeError: undefined is not a constructor (evaluating 'new brorand.Rand()')
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (7 by maintainers)
Hello! I’ve resolved this issue by importing crypto just after shim.js This is my app.js
@micimize great to hear! Yes, for some cases rewrite-require is enough. But due to a number of incompatibilities between the react-native packager and webpack/browserify, there’s a number of hacks/patches rn-nodeify uses (see https://github.com/tradle/rn-nodeify/blob/master/pkg-hacks.js)
Not sure if everyone has got this working yet but I had the same problem and after messing with it for a while I got it working.
rm -rf node_modules
rm shim.js
npm install
rn-nodeify --hack --install
And it worked! A couple things to note.
bignumber.js
(that’s required by web3.js) a while back to work with the proper crypto library, but removed the hack sincern-nodeify
solves the issue.I’m not 100% sure what combination of all of this worked but it’s currently working for me.