React Native: "Cannot find native module" error

13k Views Asked by At

In my React Native app, I'm trying to add the expo-mail-composer package using this guide.

I use [email protected],
I added "install-expo-modules": "^0.2.8",
then "expo-mail-composer": "~11.3.0",

When I try to import the package with

import * as MailComposer from 'expo-mail-composer'

it throws the error

Cannot find native module 'ExpoMailComposer'
2

There are 2 best solutions below

0
On

To use expo modules in a non-expo project (aka bare workflow), you need to install Expo modules first with:

npx install-expo-modules@latest

https://docs.expo.dev/bare/installing-expo-modules/

1
On

This issue was resolved for me by creating a new development build:

eas build --profile development --platform android

Then downloading and installing that build on my device:

adb install --user 0 <path_to_apk>

I then ran the app with:

set APP_ENV=development&& npx expo start --dev-client

The app opened as normal after that, and MailComposer.composeAsync() appears to work.

(For reference, I'm developing on a physical Android device using the Managed workflow, and did not have to use npx install-expo-modules@latest.)