Error: 🟥 @prisma/react-native failed to initialize
Here are the steps I've taken and how I built the project:
Firstly, I've made the expo project:
npx create-expo-app@latest
Then I cd into the project and install the dependencies:
npm install
Then I connected the expo app to the expo go dashboard:
eas init --id <id_string>
Then I run the app on the ios simulator:
npx expo start --ios
Everything is good and works, so I go ahead and install prisma:
npm i --save --save-exact @prisma/client@latest @prisma/react-native@latest react-native-quick-base64
then I modify the app.json plugin section as follow:
{
"expo": {
// ... The rest of your expo config
"plugins": ["@prisma/react-native"]
}
}
Then I run the following:
npx expo prebuild --clean
Then I initialize prisma
npx prisma init
Then I edit the schema with the following models:
generator client {
provider = "prisma-client-js"
previewFeatures = ["reactNative"]
}
datasource db {
provider = "sqlite"
url = "file:./app.db"
}
// Your data model
model User {
id Int @id @default(autoincrement())
name String
}
Then I run a migration:
npx prisma@latest migrate dev
Then I generate prisma:
npx prisma@latest generate
Then I make a db.ts file to use reactive queries:
import { PrismaClient } from '@prisma/client/react-native';
import { reactiveHooksExtension } from '@prisma/react-native';
const baseClient = new PrismaClient();
export const extendedClient = baseClient.$extends(reactiveHooksExtension());
Then I modify my component to use prisma:
import { Text } from 'react-native';
import { extendedClient } from './myDbModule';
export default function App {
// Will automatically re-render the component with new data
const users = extendedClient.user.useFindMany();
return (
<Text>{ users }</Text>
)
}
I'm on the latest build as of September 28, 2024
I'm getting the Error:
Here are the steps I've taken and how I built the project:
Firstly, I've made the expo project:
Then I cd into the project and install the dependencies:
Then I connected the expo app to the expo go dashboard:
Then I run the app on the ios simulator:
Everything is good and works, so I go ahead and install prisma:
then I modify the app.json plugin section as follow:
Then I run the following:
Then I initialize prisma
Then I edit the schema with the following models:
Then I run a migration:
Then I generate prisma:
Then I make a db.ts file to use reactive queries:
Then I modify my component to use prisma:
Then I restart the app:
Then I get this error: