error when trying to use speakeasy from a react-native project

741 Views Asked by At

error: bundling failed: "Unable to resolve module crypto from myproject/node_modules/speakeasy/index.js: Module does not exist in the module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman watch-del-all.\n 2. Delete the node_modules folder: rm -rf node_modules && npm install.\n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache."

Following the suggested steps doesn't seem to do any good.

Also tried to yarn add react-native-crypto but that didn't help either.

2

There are 2 best solutions below

0
On BEST ANSWER

I was using rn-nodeify but limiting it to specific modules.

As described https://www.npmjs.com/package/rn-nodeify, one can run rn-nodeify --install --hack and int takes care of the crypto lib among others.

0
On

Since this package is originally for Node.js, therefore they are not including inherited packages like crypto , util and url from the Node.js itself in the dependencies in package.json

Since some of them are deprecated therefore you can't use it as is.

  • Crypto (deprecated)

    This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.

  • Util (link here)
  • Url ( link here)