Using Crypto and Random libraries to fix dependencies using native crypto module

Please provide the following:

  1. SDK Version: 41.0.1
  2. Platforms(Android/iOS/web/all): Android iOS

I have a dependency that uses the native nodejs crypto module. I installed the Crypto and Random libraries in the hopes of fixing this issue. The project builds but I get the following error when the app encounters the code using crypto.

TypeError: undefined is not an object (evaluating ‘crypto_1.default.randomBytes’)

Maybe the libraries are not capable of handling dependencies that use the crypto module and only handles the use case of using crypto directly in your app? Or is there some additional setup that can be done for example in the metro.config.js to fix this? Any help or guidance is appreciated.

Did you find a solution for this? I have a similar error regarding a package requiring crypto

Unfortunately no. The package is made internally so we were able to just reimplement it with expo-crypto to support mobile. Not ideal but it just looked like the cleanest solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.