Unable to resolve module 'crypto'
rhrahul opened this issue · 1 comments
Hey,
I am facing this issue,
error: bundling failed: Error: Unable to resolve module "crypto" from "..\myProject\node_modules\speakeasy\index.js": Module "crypto" does not exist in the Haste module map
I am using React Native v0.57.7
Any Suggestions Please ?
According to an item on stackoverflow.
The crypto module is a built-in Node module; React Native runs JS on JavaScriptCore (when on the device or simulator) and on Chrome itself (when using Chrome debugging), so modules that depend on built-in Node.js modules cannot work. See the JavaScript Runtime section of the React Native docs for more info.
There are two solutions.
- The solution you can do only using crypto is to use browserify.
https://hackernoon.com/using-core-node-js-modules-in-react-native-apps-64acd4d07140
But as you’ll see, this is not straightforward.
- You can have a two factor authentication api on a server built in nodejs, that way, you will be able to use crypto module easily.