tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.26k stars 1.92k forks source link

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

Open Leli1024 opened 1 week ago

Leli1024 commented 1 week ago

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

paradite commented 1 week ago

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:

gaikwadrahul8 commented 5 days ago

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.

Leli1024 commented 2 days ago

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