davidbau / seedrandom

seeded random number generator for Javascript
2.04k stars 160 forks source link

compatibility with react-native #31

Closed gre closed 6 years ago

gre commented 8 years ago

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") ?

davidbau commented 8 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?

gre commented 8 years ago

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.

vespakoen commented 8 years ago

Working on supporting this natively: https://github.com/facebook/node-haste/pull/46

ammichael commented 8 years ago

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)

davidbau commented 7 years ago

@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?