'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:
- Clear watchman watches: watchman watch-del-all
- Delete node_modules
- Run yarn install Reset Metro's cache: yarn start --reset-cache
- Remove the cache: rm -rf /tmp/metro-*
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?
Solution 1:[1]
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'
}
},
],
]
};
};
`
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sam |
