5

I imported this library https://github.com/THCLab/oca.js-form-core in my React Native project but I get an error when instantiating const ocaJs = new OcaJs({});: Error: Automatic publicPath is not supported in this browser, js engine: hermes

The library is Node.js compatible (there is an example in the Github repository). However, it is packaged (npm) with webpack and I believe that the React Native project uses this package for import. That's the problem (i think - i'm a beginner in React Native). There are references to the DOM added by webpack. Is there any way to force the use of the Node.js build instead?

foxbike
  • 51
  • 1
  • You seem to have already raised an issue on the Github project. Did you provide and example project for the project maintainer to see the issue? – phuzi Jul 12 '22 at 11:48
  • Hey, just want to add that JS used by react-native is not compatible with all features of node.js. Few JS features are broken and missing in react-native. – Raj Rohit Yadav Jul 12 '22 at 20:10
  • This can be useful https://stackoverflow.com/questions/38055510/different-main-entry-point-in-package-json-for-node-and-browser – Konrad Jul 18 '22 at 22:47

1 Answers1

1

Have you tried specifying the publicPath explicitly as discussed in the answers to this question?

In general however, because React Native does not contain all the Core Node JS Modules, many libraries which are compatible with Node.js require polyfills to work in React Native. You can attempt to make a polyfill yourself by following a guide such as this. I have experienced mixed results with such methods, but I am far from an expert. From my experience, trying to create a polyfill can be a time consuming venture to pursue, and I would recommend first exploring whether or not a React Native library exists which can help you accomplish your objective.

William Trevena
  • 256
  • 2
  • 6