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 Resolving react-native-executorch Module in React Native App #130

Open
pawan-30 opened this issue Mar 9, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@pawan-30
Copy link

pawan-30 commented Mar 9, 2025

Description

Error Resolving react-native-executorch Module in React Native App

Description

I attempted to run the Llama model inside my React Native app using the react-native-executorch library. I followed the setup instructions provided in the library’s GitHub repository, but upon running the app, I encountered a module resolution error.

The error message states:

While trying to resolve module react-native-executorch, the package was found, but the main module field could not be resolved (lib/commonjs/index.js does not exist).

This suggests that the expected entry file (index.js) is missing inside the lib/commonjs/ directory of the react-native-executorch package. As a result, the module fails to load when the application starts.

Steps Taken:

  1. Installed react-native-executorch using:
    npx expo install react-native-executorch
  2. Followed the official documentation and added the necessary imports and model initialization code to my React Native component.
  3. Attempted to run the app using:
    npx expo start
  4. Encountered the module resolution error in the terminal and the app failed to start.
  5. Tried clearing the cache with:
    npx react-native start --reset-cache
    

Image
Image

However, the issue persisted.
I have attached screenshots of the error and my code for reference. Any guidance on resolving this issue would be appreciated!

Steps to reproduce

  1. Create a new React Native project using Expo or React Native CLI.
  2. Install the react-native-executorch package:
    npx expo install react-native-executorch
  3. Import and initialize the Llama model as per the official documentation.
  4. Run the app using:
    npx expo start
  5. Observe the error indicating that react-native-executorch cannot resolve its main module.

Snack or a link to a repository

https://github.com/pawan-30/react-native-executorch-bug

React Native Executorch version

0.2.0

React Native version

0.76.7

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

AI model

LLAMA3_2_1B_QLORA

Performance logs

No response

Acknowledgements

Yes

@jakmro jakmro added the bug Something isn't working label Mar 9, 2025
@chmjkb
Copy link
Contributor

chmjkb commented Mar 10, 2025

Hi!
I tried running the app but it failed with a different error on my machine (not coming from react-native-executorch). I changed metro config to this one and it seems to work but also, I can see that you're trying to run the library with Expo Go. As mentioned in the docs, we do not support Expo Go since our library uses native code. You can try running the app with:
yarn prebuild
and then running:
cd ios && pod install && cd .. && yarn expo run:ios -d
or:
yarn expo run:android -d
Let me know if that works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants