Open zerobamcoding opened 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
Hi there!
Could you share additional details of what you did and the full error message you are seeing?
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:
{
"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
}
Same issue!
Same issue!
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.
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 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.
Same issue! does anyone fixed it ?
I also have this issue sadly.
I fixed this error by running a pod install
sadly, facing the same issue, and pod install don't work on window(i guess)
same issue
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 .
Same issue!
im having the same issue as well, i might as well go back to pure sql as of the moment.
create a new empty file
baseClient.web.ts
How would this fixes this issue?
Any news on this issue? I tried every possible scenarios and it just won't work.
Hi there!
Could you share additional details of what you did and the full error message you are seeing?