Trouble building apk with expo

I’m trying to build my app into an apk via expo build:android -t apk, and I get the following error:

Failed building JavaScript bundle.
While trying to resolve module crypto from file C:\Users\USER\Desktop\Programming\Twitter\HiverMobile\node_modules\@steemit\rpc-auth\lib\index.js, the package C:\Users\USER\Desktop\Programming\Twitter\HiverMobile\node_modules\crypto\package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (C:\Users\USER\Desktop\Programming\Twitter\HiverMobile\node_modules\crypto\index.js. Indeed, none of these files exist:

  • C:\Users\USER\Desktop\Programming\Twitter\HiverMobile\node_modules\crypto\index.js(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|… and it continues with a list of files.

Here’s my expo diagnostics:
Expo CLI 3.21.13 environment info:
System:
OS: Windows 10 10.0.18363
Binaries:
Node: 12.16.3 - C:\Program Files\nodejs\node.EXE
npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6514223
npmPackages:
expo: ~38.0.1 => 38.0.3
react: ~16.11.0 => 16.11.0
react-dom: ~16.11.0 => 16.11.0
react-native: https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz => 0.62.2
react-native-web: ~0.11.7 => 0.11.7

For anyone coming across the same type of error, the issue is that react native doesn’t support the node standard library. So the node crypto library won’t work.

Thanks for sharing the solution with us @revolutionist. In case you weren’t already aware, we do have a Crypto module built into Expo. https://docs.expo.io/versions/v38.0.0/sdk/crypto/

Cheers,
Adam

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