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

Error: 🟥 @prisma/react-native failed to initialize #39

Open
xavier-brandares opened this issue Sep 28, 2024 · 6 comments
Open

Error: 🟥 @prisma/react-native failed to initialize #39

xavier-brandares opened this issue Sep 28, 2024 · 6 comments

Comments

@xavier-brandares
Copy link

I'm on the latest build as of September 28, 2024

I'm getting the Error:

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>
  )
}

Then I restart the app:

npx expo start --ios

Then I get this error:

Simulator Screenshot - iPhone 16 Plus - 2024-09-28 at 09 27 28

@xavier-brandares
Copy link
Author

xavier-brandares commented Sep 28, 2024

Related issue 23 is still open and has not been resolved.

I use prisma for NextJS and it works flawlessly, sucks that this issue completely hard locks the package.

@t0piCyb
Copy link

t0piCyb commented Oct 28, 2024

I've got the same problem just for android, it's ok for ios but android throws this error

@piscopancer
Copy link

piscopancer commented Nov 12, 2024

you may have messed the order of commands
or
after generating native code try running your app with expo start --dev-client command on your emulator, it works for me

@Prathamesh01110
Copy link

Prathamesh01110 commented Nov 17, 2024

@piscopancer i tried doing it but it didn't worked too
i did cd android and ./gradlew clean
and then npx expo start --dev-client
still got the same error

i will get you the exact code(by making you collaborator for private repo) will you try to run and fix and tell me the problem

@abc-tiago
Copy link

I've tried everything and mine always gives the same error.
I'm trying to use expo 52 react native 0.76 and the version is recent from react-native-prisma

`> Task :prisma_react-native:configureCMakeDebug[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':prisma_react-native:configureCMakeDebug[arm64-v8a]'.

[CXX1429] error when building with cmake using /Users/tiago.henrique/Documents/www/abc/pagseguro/abc/node_modules/@prisma/react-native/android/CMakeLists.txt: -- The C compiler identification is Clang 17.0.2
-- The CXX compiler identification is Clang 17.0.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/tiago.henrique/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/tiago.henrique/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done

C++ build system [configure] failed while executing:
/Users/tiago.henrique/Library/Android/sdk/cmake/3.22.1/bin/cmake
-H/Users/tiago.henrique/Documents/www/abc/pagseguro/abc/node_modules/@prisma/react-native/android
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_SYSTEM_VERSION=24
-DANDROID_PLATFORM=android-24
-DANDROID_ABI=arm64-v8a
-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
-DANDROID_NDK=/Users/tiago.henrique/Library/Android/sdk/ndk/26.1.10909125
-DCMAKE_ANDROID_NDK=/Users/tiago.henrique/Library/Android/sdk/ndk/26.1.10909125
-DCMAKE_TOOLCHAIN_FILE=/Users/tiago.henrique/Library/Android/sdk/ndk/26.1.10909125/build/cmake/android.toolchain.cmake
-DCMAKE_MAKE_PROGRAM=/Users/tiago.henrique/Library/Android/sdk/cmake/3.22.1/bin/ninja
"-DCMAKE_CXX_FLAGS=-O2 -fexceptions -frtti -DONANDROID -lz"
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/tiago.henrique/Documents/www/abc/pagseguro/abc/node_modules/@prisma/react-native/android/build/intermediates/cxx/Debug/a126rx2x/obj/arm64-v8a
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/tiago.henrique/Documents/www/abc/pagseguro/abc/node_modules/@prisma/react-native/android/build/intermediates/cxx/Debug/a126rx2x/obj/arm64-v8a
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_FIND_ROOT_PATH=/Users/tiago.henrique/Documents/www/abc/pagseguro/abc/node_modules/@prisma/react-native/android/.cxx/Debug/a126rx2x/prefab/arm64-v8a/prefab
-B/Users/tiago.henrique/Documents/www/abc/pagseguro/abc/node_modules/@prisma/react-native/android/.cxx/Debug/a126rx2x/arm64-v8a
-GNinja
-DANDROID_STL=c++_shared
from /Users/tiago.henrique/Documents/www/abc/pagseguro/abc/node_modules/@prisma/react-native/android
CMake Error at CMakeLists.txt:10 (add_library):
Target "react-native-prisma" links to target
"ReactAndroid::turbomodulejsijni" but the target was not found. Perhaps a
find_package() call is missing for an IMPORTED target, or an ALIAS target
is missing?

CMake Error at CMakeLists.txt:10 (add_library):
Target "react-native-prisma" links to target
"ReactAndroid::react_nativemodule_core" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?`

@Jamie-Fairweather
Copy link

I've tried everything and mine always gives the same error. I'm trying to use expo 52 react native 0.76 and the version is recent from react-native-prisma

`> Task :prisma_react-native:configureCMakeDebug[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':prisma_react-native:configureCMakeDebug[arm64-v8a]'.

Ive just opened a new issue for this part, ive included a fix :) #47

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

6 participants