-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use react-native-crypto to support react native environments. #259
base: develop
Are you sure you want to change the base?
Conversation
@alexyangjie this pull request is about to create a React Native compatible version using crypto module. I do not have a ready to use React Native environment setup. If you like to test it, here are the steps to go:
|
I currently don't have much time to test this. Will probably come back later when I have some time. Thanks. |
Result:
|
@Bardiamist this is indeed weird, as it looks like the try catch block does not catch in this case.
|
I don't have I tried Result:
|
The Therefor In case it fails the is another Well the problem seems to be the usage of a bundler, as the bundler is doing static analysis and is trying to add Right now I'm not sure how to handle is on bundler level. |
db68377
to
0601221
Compare
Just a note Installing
In my case I decided to go with I would consider if this library might work out without the need to install the entire |
straightforward solution: delete that will fix the issues on RN 0.60+. (tested in RN 0.61) If a fallback is needed, |
Another solution which doesn't require any changes to crypto-js is to use the metro bundler config (https://facebook.github.io/metro/docs/en/configuration#extranodemodules) to point the module.exports = {
resolver: {
extraNodeModules: {
crypto: './node_modules/react-native-crypto,
},
},
}; A lighter polyfill could be https://github.com/LinusU/react-native-get-random-values, but it doesn't seem to be very up to date. For more info how this works, see https://github.com/parshap/node-libs-react-native#usage-with-react-native-packager |
react native(metro) does not support conditional require(no runtime require) |
Update: seems you are right |
@Bardiamist That's different. Metro will force every require exists. |
Hey, is there any news about this? |
I can confirm that problem in Can we remove it? And find another solution for NodeJS developers. @aeirola Thanks for the solution. I'll just import
I want fork
|
Althought I'm not a fan of adding a whole librairie just to get rid of an error, doing a npm i --save react-native-crypto, and then adding this code to the metro.config.js file did get rid of the error. Thanks. |
a package.json config |
I made this by using crypto-es lib instead. |
i have same issue like Error: Unable to resolve module If you are sure the module exists, try these steps:
in react native if some one have any answer then please tell me i learning react native and at morning my project was running perfectly but from last 3 hour i face this issue so please help me on this thanks in advance :) |
In React native 0.64.0 Instruction:
|
So the RN issue for 4.x is gone and this PR is subject to close, the final task is adding RN-related instructions back to the README... |
@vincicat Could you add it to the README? |
my |
Works for me RN 0.70.6 |
Thanks! Works for me! RN 0.71.6 |
Thank you! It's works for me RN 0.71.8 |
What to do if in my |
React native 0.71.8 have it by default https://github.com/facebook/react-native/blob/0.71-stable/template/metro.config.js |
Big Thanks @Bardiamist 🙏🏾🙏🏾 |
I spent 2 days to solve the issue, I have I installed Then imported After hours of debugging, I found it's Babel's compiling order issue. My file was:
The fix was lowering the compile order of
|
I Got This Error Any one Help for this Removing Error
|
No description provided.