Open diosney opened 4 years ago
I just ran into this too... my solution was to create this https://www.npmjs.com/package/random-js-no-node
Definitely a massive hack, but it worked!
I honestly don't know much about modules/packaging/etc, but the basic problem seems to be this: in the browser, random-js successfully makes 'crypto' an optional dependency, but somehow in the context of React Native, it's not. I imagine that something sees the require("crypto")
call in the node engine, and decides that crypto is a required dependency.
I faced the same issue. Please share more examples how to solve.
I would suggest using a polyfill or similar that hooks to the module crypto-browserify
I commented code with 'crypto' and everything still works.
PR #65 may provide a fix for this issue Also @Spacerat you'll likely need to update your repo once it merges because it will be a HUGE, sorely needed update
That's interesting - if #65 fixes this issue, I think my repo would be made redundant? In which case I wonder if it's better to deprecate it than keep it updated.
That's interesting - if #65 fixes this issue, I think my repo would be made redundant? In which case I wonder if it's better to deprecate it than keep it updated.
yeah, as there's ways to do the same thing as what random-js-no-node
does now with webpack 5+ polyfills
Currently if used on React Native, it throw an error stating that
crypto
module wasn't found.Tested with the following code: