Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zerobamcoding opened this issue Jun 14, 2024 · 17 comments
Open

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

zerobamcoding opened this issue Jun 14, 2024 · 17 comments

Comments

@zerobamcoding
Copy link

No description provided.

@sorenbs
Copy link
Member

sorenbs commented Jun 17, 2024

Hi there!

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

@ImranArtwel
Copy link

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
Copy link

vearvip commented Jun 21, 2024

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:

  • Node: v18.17.1
  • Android: 14
  • Simulator: Pixel_3a_API_34
  • MacOS: Ventura 13.0.1
{
  "name": "ceshi",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --watchAll",
    "lint": "expo lint"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^14.0.0",
    "@prisma/client": "5.15.1",
    "@prisma/react-native": "5.15.1",
    "@react-navigation/native": "^6.0.2",
    "expo": "~51.0.14",
    "expo-constants": "~16.0.2",
    "expo-font": "~12.0.7",
    "expo-linking": "~6.3.1",
    "expo-router": "~3.5.16",
    "expo-splash-screen": "~0.27.5",
    "expo-status-bar": "~1.12.1",
    "expo-system-ui": "~3.0.6",
    "expo-web-browser": "~13.0.3",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.74.2",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-quick-base64": "2.1.2",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.1",
    "react-native-screens": "3.31.1",
    "react-native-web": "~0.19.10"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.2.45",
    "@types/react-test-renderer": "^18.0.7",
    "jest": "^29.2.1",
    "jest-expo": "~51.0.1",
    "react-test-renderer": "18.2.0",
    "typescript": "~5.3.3"
  },
  "private": true
}

@trongthienpc
Copy link

Same issue!

1 similar comment
@FasterSt
Copy link

Same issue!

@Palladd
Copy link

Palladd commented Jul 15, 2024

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
Copy link

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
Copy link

Palladd commented Jul 16, 2024

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
Copy link

Same issue! does anyone fixed it ?

@NyakoFox
Copy link

I also have this issue sadly.

@jennmueng
Copy link

I fixed this error by running a pod install

@yogeshprakhar
Copy link

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

@n0xgg04
Copy link

n0xgg04 commented Aug 8, 2024

same issue

@Jamie-Fairweather
Copy link

Jamie-Fairweather commented Aug 14, 2024

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
Copy link

hakimLyon commented Aug 16, 2024

Same issue!
Capture

@bangueco
Copy link

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
Copy link

hyochan commented Oct 20, 2024

create a new empty file baseClient.web.ts

How would this fixes this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests