speakeasyjs / speakeasy

**NOT MAINTAINED** Two-factor authentication for Node.js. One-time passcode generator (HOTP/TOTP) with support for Google Authenticator.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to resolve module 'crypto'

rhrahul opened this issue · 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.

  1. 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.

  1. 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.