@@ -13,6 +13,29 @@ declare global {
13
13
var __PrismaProxy : PrismaProxy | undefined ;
14
14
}
15
15
16
+ const errorResolutions = [
17
+ `1. Ensure @prisma/react-native is added to the plugins section in app.json` ,
18
+
19
+ `2. Ensure at least one migration exists:
20
+
21
+ $ prisma migrate dev` ,
22
+
23
+ `3. Try removing the node_modules/ folder and running the prebuild command:
24
+
25
+ $ rm -rf node_modules/
26
+ $ npx expo prebuild --clean
27
+ ` ,
28
+ `4. If in a monorepo, ensure the application's package.json also has the required Prisma dependencies:
29
+
30
+ $ npm i @prisma/client@latest @prisma/react-native@latest react-native-quick-base64
31
+ $ yarn add @prisma/client@latest @prisma/react-native@latest react-native-quick-base64
32
+ ` ,
33
+ ] ;
34
+
35
+ const makeErrorMessage = ( message : string ) => {
36
+ return [ message , errorResolutions . join ( '\n\n' ) ] . join ( '\n\n' ) ;
37
+ } ;
38
+
16
39
// @ts -expect-error
17
40
const isTurboModuleEnabled = global . __turboModuleProxy != null ;
18
41
@@ -21,13 +44,23 @@ const PrismaModule = isTurboModuleEnabled
21
44
: NativeModules . Prisma ;
22
45
23
46
if ( ! PrismaModule ) {
24
- throw new Error ( '🟥 @prisma/react-native failed to initialize' ) ;
47
+ throw new Error (
48
+ makeErrorMessage ( '🟥 @prisma/react-native failed to initialize' )
49
+ ) ;
25
50
}
26
51
27
- PrismaModule . install ( ) ;
52
+ try {
53
+ PrismaModule . install ( ) ;
54
+ } catch {
55
+ throw new Error (
56
+ makeErrorMessage ( `🟥 @prisma/react-native failed to install` )
57
+ ) ;
58
+ }
28
59
29
60
if ( ! global . __PrismaProxy ) {
30
- throw new Error ( '🟥 prisma/react-native C++ bindings failed to initialize' ) ;
61
+ throw new Error (
62
+ makeErrorMessage ( '🟥 prisma/react-native C++ bindings failed to initialize' )
63
+ ) ;
31
64
}
32
65
33
66
// Wrap the create function to stringify the env variables if necessary
0 commit comments