For the past month, I've been diligently working on a react native component library, and I believe it's finally in a state where I can publish it as a package on npm. After pushing it to GitHub and running npm publish
, everything seemed to be running smoothly.
In the process of publishing it, I made some changes to my index.ts
:
// index.ts
import createRComps from 'Base.tsx';
export default createRComps; // This is the primary object I need to export since it calls others from within itself
I also attempted using create-react-native-library
on a separate copy of the repository, but that didn't yield any more success.
Now, I've set up a new react native project to test my new library: I installed it using npm i react-native-ready-comps
, and included some of my library's code:
export default function App() {
const RComps = createRComps(); // main function of my library
return (
<RComps.Title bold>Hello world!</RComps.Title> // utilizing one of my library's components
);
}
However, when I tried to run it using metro (
npx react-native run-android && npx react-native start
), I encountered the following error:
ERROR TypeError: Cannot read property 'createNode' of null, js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
I suspect the error is coming from my library, although I didn't experience this issue during its development phase. Could it be something I missed during the publishing process?
If you could shed some light on what I might have done wrong, and if you have any resources on exporting a react native component library, I would greatly appreciate it! My searches on Google and Stack Overflow haven't provided much help.
Thank you so much!
PS: Here is the repository for my library if you'd like to review the code. Due to it being a project issue, I'm unable to create a minimal reproducible example...