tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

TypeError: Cannot read property 'NativeModule' of undefined, js engine: hermes

Open Leli1024 opened this issue 1 year ago • 16 comments

Im using the latest versions of react native and the tfjs package. But when ai try to import bundleIOResources specifically. I get the error TypeError: Cannot read property 'NativeModule' of undefined, js engine: hermes

My project does not use expo, it is not an expo managed app

Leli1024 avatar Jun 29 '24 11:06 Leli1024

Taking a look at the code (I worked on it before), it seems to require some other libraries like expo-asset to work: https://github.com/tensorflow/tfjs/blob/master/tfjs-react-native/src/bundle_resource_io.ts

If you are not using expo, you might not have those libraries then it won't work. I think if you install expo-asset manually it should work.

You can also take what you need from tfjs-react-native/src/platform_react_native.ts into your own repo and then add whatever storage you need manually:

  • async storage https://github.com/tensorflow/tfjs/blob/master/tfjs-react-native/src/async_storage_io.ts
  • bundle resource https://github.com/tensorflow/tfjs/blob/master/tfjs-react-native/src/bundle_resource_io.ts
  • mmkv https://github.com/ai-simulator/tfjs-react-native-mmkv-storage (written by me)

paradite avatar Jun 30 '24 12:06 paradite

Hi, @Leli1024

I apologize for the delay in my response. Have you had a chance to try the workaround mentioned by @paradite in the previous comment? If so, please let me know if the issue has been resolved or if you are still encountering problems.

Thank you for your cooperation and patience.

gaikwadrahul8 avatar Jul 02 '24 13:07 gaikwadrahul8

Thanks both, I tried the workaround on my bare project and it did not work, but when I coded a dummy app using expo, it did so I'm assuming it is not working because these dependencies just don't work with react native bare projects.

Another thing to note is that when trying to run predictions on images, the app crashes

Leli1024 avatar Jul 05 '24 13:07 Leli1024

i am facing ERROR in react native project and I am unable to solve to these errors anyone can share the solution of these errors
TypeError: Cannot read property 'NativeModule' of undefined, js engine: hermes LOG Running "AwesomeProject" with {"rootTag":171} ERROR Invariant Violation: "AwesomeProject" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called., js engine: hermes
image

Usama-Nazir avatar Aug 29 '24 07:08 Usama-Nazir

J'ai exactement le même problème, si on peut m'aider (nous aider), c'est génial. As-tu corrigé le problème ? Si oui, comment stp ?

Adelkunagi avatar Sep 03 '24 09:09 Adelkunagi

I have same issue, i installed expo-av in my project and i get it this error. image

BerkYxvuz avatar Sep 12 '24 16:09 BerkYxvuz

@Usama-Nazir Same issue here. Where you able to solve it?

brunopintos avatar Sep 17 '24 11:09 brunopintos

anymore progress here? same issue for me

TomGroombridge avatar Sep 20 '24 12:09 TomGroombridge

Same issue here.

Gugarauj07 avatar Sep 22 '24 18:09 Gugarauj07

Hi everyone, I haven't used this library recently, but this error is usually a sign that your native modules are not loaded.

This could happen if you use expo go, and it's missing a required native module. Expo team decides which modules are included in expo go, so it could be that they removed a module required by tfjs in expo go.

In any case, you should use expo dev client for development and testing, in which you can control which native modules are installed.

Hope this helps.

paradite avatar Sep 23 '24 04:09 paradite

Same issue here.

Kotchanit avatar Sep 25 '24 07:09 Kotchanit

This issue is not related to tensorflow it seems, but to expo - I think. But I also couldn't detect where it specifically comes from in my case.

Related to: https://github.com/expo/expo/issues/29568 https://github.com/expo/expo/issues/31018

dimisus avatar Sep 25 '24 10:09 dimisus

The same error occurs when using Expo assets.

leeminwuk avatar Sep 28 '24 09:09 leeminwuk

The same error occurs when attached the react-native-debugger "react-native": "0.75.2", "expo": "^51.0.0", "expo-file-system":"~17.0.1", "expo-image-picker": "~15.0.7", "expo-media-library": "~16.0.5",

Image

rizwan-gill avatar Jan 23 '25 07:01 rizwan-gill

I used bare project

Step 2: Install dependencies Note that if you are using in a managed expo app the install instructions may be different.

Install and configure react-native-unimodules (can be skipped if in an expo app) Install and configure expo-gl Install and configure expo-camera Install and configure async-storage Install and configure react-native-fs Install @tensorflow/tfjs - npm install @tensorflow/tfjs Install @tensorflow/tfjs-react-native - npm install @tensorflow/tfjs-react-native

I edited the tutorial on GitHub. it occured same error

Is there any solution?

pparkgyuhyeon avatar May 14 '25 04:05 pparkgyuhyeon