prisma / react-native-prisma

Apache License 2.0
200 stars 9 forks source link

@prisma/react-native failed to initialize, js engine: hermes #23

Open zerobamcoding opened 5 months ago

sorenbs commented 5 months ago

Hi there!

Could you share additional details of what you did and the full error message you are seeing?

ImranArtwel commented 5 months ago

I have the same error from doing this:

import "@prisma/react-native";

import { PrismaClient } from "@prisma/client/react-native";

const prisma = new PrismaClient({
  log: [{ emit: "event", level: "query" }],
});

export async function initializeDB() {
  try {
    await prisma.$applyPendingMigrations();
  } catch (e) {
    console.error(`failed to apply migrations: ${e}`);
    throw new Error(
      "Applying migrations failed, your app is now in an inconsistent state. We cannot guarantee safety, it is now your responsability to reset the database or tell the user to re-install the app"
    );
  }
}

export default prisma;

calling this in the useEffect of the first route index.tsx

vearvip commented 5 months ago

Hi there!

Could you share additional details of what you did and the full error message you are seeing?


I encountered the same issue

First, I followed the tutorial from the Expo official website and used the following command to create a local test project:

npx create-expo-app@latest

Then I executed the following command to get a clean project:

npm run reset-project

Next, as per the project's README, I installed the dependencies:

npm i --save --save-exact @prisma/client@latest @prisma/react-native@latest react-native-quick-base64

And according to the subsequent steps in the README, I completed the project initialization:

{
  "expo": {
    // ... The rest of your expo config
    "plugins": ["@prisma/react-native"]
  }
}
npx expo prebuild --clean

I placed schema.prisma in /prisma/schema.prisma:

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["reactNative"]
}
datasource db {
  provider = "sqlite"
  url      = "file:./app.db"
}
model User {
  id           Int     @id @default(autoincrement())
  name         String
}

I also executed the following commands:

npx prisma@latest migrate dev
npx prisma@latest generate

Finally, I modified the code in index.ts as follows:

import { Text, View } from "react-native";
import { PrismaClient } from '@prisma/client/react-native';
import { reactiveHooksExtension } from '@prisma/react-native';
const baseClient = new PrismaClient();
export const extendedClient = baseClient.$extends(reactiveHooksExtension());
export default function Index() {
  const users = extendedClient.user.useFindMany(); 
  return (
    <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
      }}
    >
      <Text>hello world</Text>
      <Text>{JSON.stringify(users)}</Text>
    </View>
  );
}

However, when I run the project, it displays the following error message:

Android Bundled 7035ms node_modules/expo-router/entry.js (959 modules)
 ERROR  Error: 🟥 @prisma/react-native failed to initialize, js engine: hermes 

My development environment is as follows:


trongthienpc commented 5 months ago

Same issue!

FasterSt commented 4 months ago

Same issue!

Palladd commented 4 months ago

Same... idk what's the problem right here, bcs I just can't figure it out. I've made even a new, clean expo project and it still doesn't works.

andrewbaisden commented 4 months ago

I have the same issue as well it's linked to this one Prisma Integration Errors in React Native with Expo: Warnings and Import Failures

Palladd commented 4 months ago

I have the same issue as well it's linked to this one Prisma Integration Errors in React Native with Expo: Warnings and Import Failures

I saw it and it even seems that's the most popular problem right now about this.

SyntaxFear commented 4 months ago

Same issue! does anyone fixed it ?

NyakoFox commented 3 months ago

I also have this issue sadly.

jennmueng commented 3 months ago

I fixed this error by running a pod install

yogeshprakhar commented 3 months ago

sadly, facing the same issue, and pod install don't work on window(i guess)

n0xgg04 commented 3 months ago

same issue

Jamie-Fairweather commented 3 months ago

Same issue here with android. Seems that NativeModules.Prisma from react-native is null, causing the error

Edit: After a little more digging, this cause for me was because I'm using Expo Go, which doesn't support Native Modules .

hakimLyon commented 3 months ago

Same issue!

Capture
bangueco commented 2 months ago

im having the same issue as well, i might as well go back to pure sql as of the moment.

Screenshot from 2024-08-25 17-23-38

hyochan commented 1 month ago

create a new empty file baseClient.web.ts

How would this fixes this issue?

eblancperso commented 1 week ago

Any news on this issue? I tried every possible scenarios and it just won't work.