Hi I’m trying to use Moralis on Expo react native.
I created an expo project, then I npm install react react-moralis
.
I then input it in the App.js
import { StatusBar } from "expo-status-bar";
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { MoralisProvider } from "react-moralis";
const serverUrl = "https://xxxxxxxxxx.usemoralis.com:2053/server";
const appId = "xxxxxxxxx";
Moralis.start({ serverUrl, appId });
export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
This is the error when I load the app.
Android Bundling failed 3702ms
Unable to resolve module crypto from /home/brian/Programming/my-expo/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
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. 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');
Need your help how to fix this?