Closed gre closed 6 years ago
I'm not familiar with react-native. The hope for the try/catch was that in an environment that fails to offer crypto, seedrandom is happy to work anyway. Why isn't the try/catch working - and is there another approach that would work in react-native?
Yeah I guess because they don't resolve packages the same way. I guess browserify does provide "crypto" JavaScript implementation, I guess it should be the same for react-native so I've created an issue on react-native.
Working on supporting this natively: https://github.com/facebook/node-haste/pull/46
If anyone still have this issue (like I just did), you can rename in node_modules the folder crypto-js that you should have to just 'crypto'. Works perfectly (until you need to npm install again and forget what is causing the trouble again)
@gre and @vespakoen - in light of the fact that facebook/node-haste#46 is resolved and closed, is this issue still relevant for seedrandom.js, or will things Just Work for us on react-native?
uncaught error Error: UnableToResolveError: Unable to resolve module crypto from /Users/gre/dev/gl-react-native/Examples/Hearts/node_modules/seedrandom/seedrandom.js: Invalid directory /Users/node_modules/crypto
this is what happens in React Native, there should be a better way to detect node environment than a try catch covering the require("crypto") ?