Unable to resolve "text-encoding" from "node_modules/gun/lib/mobile.js"

97 Views Asked by At

while developing react native app getting this issue here is my code bellow.

import { REACT_APP_GUN_PEER } from "@env";
import "gun/lib/mobile.js"
import Gun from "gun/gun";
import sea from "gun/sea";
import "gun/lib/radix.js";
import "gun/lib/radisk.js";
import "gun/lib/store.js";
import "gun/lib/rindexed.js";
import asyncStore from 'gun/lib/ras.js'
import { storeLocalData } from "../Utils/utils";
import AsyncStorage from "@react-native-async-storage/async-storage";

Gun({ store: asyncStore({ AsyncStorage }) })

export const gun = new Gun(REACT_APP_GUN_PEER); // Gun relay
export const SEA = sea;

export const appDB = gun.get("ticTacToe");

export const createLocalUser = async (name) => {
  try {
    const pair = await SEA.pair();
    const user = {
      name,
      pair,
    };
    storeLocalData("user", user);
  } catch (e) {
    return e
  }
}

If I comment this import 'import "gun/lib/mobile.js"' I am getting bellow error.

ERROR Error: Dynamic require defined at line 5; not supported by Metro, js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called., js engine: hermes
0

There are 0 best solutions below