bilionjacopo
bilionjacopo

Reputation: 21

Web3 React Native Expo V4.13

With React Native Expo V4.13.0, importing the web3 V1.6.1 module, I get the following error:

Unable to resolve module crypto from /Users/black/Desktop/test/node_modules/web3-eth-accounts/lib/index.js: crypto could not be found within the project or in these directories:
node_modules/web3-eth-accounts/node_modules
node_modules
../../node_modules

If you are sure the module exists, try these steps:

24 | var Method = require('web3-core-method');
25 | var Account = require('eth-lib/lib/account');
26 | var cryp = (typeof global === 'undefined') ? require('crypto-browserify') : require('crypto');
| ^
27 | var scrypt = require('scrypt-js');
28 | var uuid = require('uuid');
29 | var utils = require('web3-utils');`

Yesterday I updated the version of expo and it no longer worked, before it worked fine.

Does anyone have the same problem?

Upvotes: 2

Views: 620

Answers (1)

Sam
Sam

Reputation: 133

I used expo-crypto for this.

Install the above package in your project yarn add expo-crypto

Add the following in your babel.config.js

module.exports = function(api) {
  ...
  return {
    ...
    plugins: [
      [
        'module-resolver',
        {
          alias: {
            crypto: './node_modules/expo-crypto'
          }
        },
      ],
    ]
  };
};
`

Upvotes: 1

Related Questions