sdk-for-react-native: 🐛 Bug Report: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found

👟 Reproduction steps

Hello together,

I am building an Expo / RN app and try to implement my authentication with the createMagicURLToken() function.

I followed all documentation steps to create my Appwrite client like the following:

import { Account, Client } from "react-native-appwrite";

const client = new Client()
  .setEndpoint("https://cloud.appwrite.io/v1")
  .setProject("PROJECT_ID")
  .setPlatform("PLATFORM");

export const account = new Account(client);

In my authentication part I use createMagicURLToken like in the docs explained:

import { ID } from "react-native-appwrite";

  try {
    const token = await account.createMagicURLToken(
      ID.unique(),
      "email@example.com",
      "URL"
    );

    return { token };
  } catch (error) {
    console.error(error);
  }

At this point, when the createMagicURLToken is executed, my application crashes with the following message:

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: true. TurboModule interop: false. Modules loaded: {"NativeModules":[],"TurboModules":[],"NotFound":["PlatformConstants"]}

ℹ I saw that this library has the following dependencies and was thinking if this might be a problem with the react-native version. I use the newest 0.77.0 like described later in my environment settings.

"dependencies": {
    "expo-file-system": "16.0.8",
    "react-native": "^0.73.6"
},

👍 Expected behavior

That the function runs through or at least giving me a better instruction what might gone wrong.

👎 Actual Behavior

Image

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

MacOS

🧱 Your Environment

I use appwrite in the cloud, so it should be v1.6.x

expo: 52.0.33 react-native: 0.77.0 react-native-appwrite: 0.7.0 react-native-url-polyfill: 2.0.0

Devices:

  • iPhone 15 Pro Max (iOS 17.2 - Simulator)
  • iPhone 14 Pro (iOS 18.1.1)

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn’t find similar issue

🏢 Have you read the Code of Conduct?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 36 (6 by maintainers)

Most upvoted comments

While we work on a permanent fix, please see if this workaround helps:

  1. Delete node_modules and package-lock.json
  2. Add this to your package.json:
  "overrides": {
    "react-native-appwrite": {
      "expo-file-system": "18.*.*",
      "react-native": ">=0.76.7 <1.0.0"
    }
  },
  1. Run npm i

currently i am getting this issue, only happened after upgrading to expo 53 and enabling newArch

this is blocking … i can’t progress with developement , this will lead to devs switching to another solution @ChiragAgg5k

this repro repo link https://github.com/abdeljalilait/platformconstants-could-not-found-repro

I upgraded to SDK 53 a few hours ago as my project was on SDK 52 and the current expo go would not work on older SDK’s im running into the same issue i checked all the react native versions and they are up to date. any updates on the situation?

I am getting this issue when i upgraded to expo 53 too

Expo 53 turned on New Architecture by default.

As a workaround to stay on the latest Expo version you should be able to opt out in your app.json:

{
  "expo": {
    "newArchEnabled": false
  }
}

Source: https://docs.expo.dev/guides/new-architecture/#disable-the-new-architecture-in-an-existing-project

Sadly this does not fix it. you can see the new architecure is disabled…

Image

@EntryRoot @JuliBlu Guys try npx expo install --fix . It worked for me. If you get peer dependency conflicts try fixing it manually by installing the compatible versions (for me I had to install react-native, react)

@akshaykumar059004 Doing npx expo install --fix didn’t change anything for me. I don’t have any dependency conflicts either. Can you share your versions for expo, react-native, react and appwrite sdk?

“react-native”: “0.79.2” “expo”: “^53.0.7” “react”: “19.0.0” I don’t use appwrite

@EntryRoot @JuliBlu Guys try npx expo install --fix . It worked for me. If you get peer dependency conflicts try fixing it manually by installing the compatible versions (for me I had to install react-native, react)

@akshaykumar059004 Doing npx expo install --fix didn’t change anything for me. I don’t have any dependency conflicts either. Can you share your versions for expo, react-native, react and appwrite sdk?

Me too guys. How to fix this? I tried downgrading RN to 0.76.5 but didn’t help.

The issue should be fixed with the latest release of the sdk via the PR - https://github.com/appwrite/sdk-generator/pull/1073

Please upgrade to version 0.7.4

just trun “newArchEnabled”: false in app.json

it’s work for me

{ “expo”: { “name”: “SCRAPX-2”, “slug”: “SCRAPX-2”, “version”: “1.0.0”, “orientation”: “portrait”, “icon”: “./assets/images/icon.png”, “scheme”: “scrapx2”, “userInterfaceStyle”: “automatic”, “newArchEnabled”: false, “ios”: { “supportsTablet”: true }, “android”: { “adaptiveIcon”: { “foregroundImage”: “./assets/images/adaptive-icon.png”, “backgroundColor”: “#ffffff” }, “edgeToEdgeEnabled”: true, “package”: “com.scrapxapp” }, “web”: { “bundler”: “metro”, “output”: “static”, “favicon”: “./assets/images/favicon.png” }, “plugins”: [ “expo-router”, [ “expo-splash-screen”, { “image”: “./assets/images/splash-icon.png”, “imageWidth”: 200, “resizeMode”: “contain”, “backgroundColor”: “#ffffff” } ] ], “experiments”: { “typedRoutes”: true } } }

While we work on a permanent fix, please see if this workaround helps:

  1. Delete node_modules and package-lock.json
  2. Add this to your package.json:

“overrides”: { “react-native-appwrite”: { “expo-file-system”: “18..”, “react-native”: “>=0.76.7 <1.0.0” } }, 3. Run npm i

Thanks, can confirm this worked for me.

@EntryRoot @JuliBlu Guys try npx expo install --fix . It worked for me. If you get peer dependency conflicts try fixing it manually by installing the compatible versions (for me I had to install react-native, react)

Unfortunatelly also didn’t do anything for me, is this issue still being looked at ?

When using latest expo go app you must use expo 53 sdk. Have you tested app write with expo 53?

Image

@abdeljalilait the issue seems like its not coming from appwrite, but due to upgrade to newer expo versions. i would try to experiment with different solutions online, and in the worst case try downgrading to previous versions

I dont think simply screenshoting errors back to 2024 is good support tbh.

a quick fix, using expo Device module can solve this issue, instead of Platform module from react native, as in the sdk itself

/// src/client.ts
import { Models } from './models';
import { Service } from './service';
import * as Device from 'expo-device'; // import { Platform } from 'react-native';
///function createsocket
 this.realtime.socket = new WebSocket(url, undefined, {
                    headers: {
                        Origin: `appwrite-${Device.osName}://${this.config.platform}`
                    }
                });

///function call
 headers.Origin = `appwrite-${Device.osName}://${this.config.platform}`

        let options: RequestInit = {
            method,
            headers,
            credentials: 'include'
        };


and i don’t think i can create a pull request with the fix. and i am not sure if this fix would even be viable with the sdk, but for now it works well, i’ve made a npm package and i am using it in my app for now

Same issue after upgrading to expo 53 and resolving all dependencies.

 ERROR  Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

Image

@nolliebigspin i see, thanks for replying. i will raise the concern with the internal team and double check to see if the issue is reproducable before closing it 👍