Hello everyone, I’m trying to use the Rudderstack...
# support
d
Hello everyone, I’m trying to use the Rudderstack React Native SDK on an Expo managed App, but haven’t been able to do so. When executing
npx expo prebuild
I get an error saying that ES Module is not supported.
Copy code
CommandError: require() of ES Module .../node_modules/@rudderstack/rudder-sdk-react-native/index.esm.js from /.../node_modules/@expo/config-plugins/build/utils/plugin-resolver.js not supported.

Instead change the require of index.esm.js in /Users/carlos/Documents/Code/Fair/equals-client-app/node_modules/@expo/config-plugins/build/utils/plugin-resolver.js to a dynamic import() which is available in all CommonJS modules.
I installed the Rudderstack SDK using
npx expo install
, and add it as a plugin on the
app.config.ts
Apparently Expo doesn’t support ES modules? Is there any workaround?
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
c
Hey @damp-ram-97063, Can you try this solution: https://stackoverflow.com/a/69089164 Add this to your package.json file:
Copy code
{ 
   "type": "module",
 }
If the issue still persists, please provide the reproducible steps so that I can investigate it properly. Also, you may create a new Expo project, try installing the RudderStack React Native SDK, and check if you encounter the error or not.
d
I’m embarrassed to say this, but the problem was that I wasn’t doing
npx expo run:android
after
npx expo prebuild --clean
, I was simply doing
npx expo start
🤦‍♂️ For anyone else that may find this message, It’s not necessary to add the Rudderstack SDK to the expo plugins. The only extra additional configuration needed is to add the iOS extra pod, since it’s not done automatically by the SDK. This can be done using the “expo-build-properties” plugin on the
app.config.ts
like this:
Copy code
expo: {
  plugins: [
    [
      "expo-build-properties",
      {
        ios: {
          extraPods: [{ name: "RSCrashReporter", modular_headers: true }],
        },
      },
    ],
  ],
}
🙌 1