expo/examples

Unable to resolve module crypto when using 'web3-eth-accounts'

Prismoid opened this issue · 0 comments

Describe the bug
When importing libraries that use crypto, I see the below error report.
-> Unable to resolve module crypto...
(The detials are shown in https://dev.to/hyetigran/unable-to-resolve-module-crypto-1gek)

To Reproduce
Steps to reproduce the behavior:
In the current working directory,

  1. expo init
  2. npm install --save web3-eth-accounts

App.js

var Accounts = require('web3-eth-accounts');
var accounts = new Accounts('ws://localhost:8546');
accounts.create(); 

Expected behavior
There are no errors.

Screenshots
If applicable, add screenshots to help explain your problem.
The below website shows an example of the error.
https://dev.to/hyetigran/unable-to-resolve-module-crypto-1gek

Desktop (please complete the following information):

  • OS: iOS
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.
The below site insists that if you want to avoid this error, you need to eject Expo.
https://dev.to/hyetigran/unable-to-resolve-module-crypto-1gek

But, if there are some solutions, I continue to use Expo.
Thank you.