Unable to build a React Native library

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...

Answer №1

Have you been able to resolve this issue?

I attempted to add your package npm i react-native-ready-comps to a test project using react native CLI.

Upon inspecting the

node-modules/react-native-ready-comps/
directory of the test project, it appears that your entire GitHub repository is being included in the package.

It might be helpful to utilize a tool like for packaging your components.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a personalized progress bar that reflects real-time data from an external API

I have developed an API that sends scores if someone solves math, chemistry, or physics problems correctly. The API responds with a JSON object like this: { "scores": { "maths": 28, "chemistry": 9, "physics": 26, } } When a person complet ...

What is the best way to adjust the placement of a component to remain in sync with the v-model it is connected to?

I am encountering an issue with 2 sliders in my project. I have set it up so that when the lower slider's value is greater than 0, the top slider should automatically be set to 5. I am using a watcher function for this purpose. However, if I manually ...

Be sure to mention the Node.js version in the package.json file to avoid using any outdated APIs

In my project, I've made the switch from using the deprecated new Buffer() constructor to Buffer.from(). Now, I need to specify the node version in my package.json. I've learned that Buffer.from() is not available in earlier minor versions of ce ...

The module "ng-particles" does not have a Container component available for export

I have integrated ng-particles into my Angular project by installing it with npm i ng-particles and adding app.ts import { Container, Main } from 'ng-particles'; export class AppComponent{ id = "tsparticles"; /* Using a remote ...

Jquery is not displaying the background color of the progress bar

Greetings to all! I am currently working on implementing a progress bar for my website, but I am encountering an issue where the background-color is not displaying correctly on scroll. I would greatly appreciate any assistance with this matter. Below you c ...

Creating a unique design on a circular target in Android: Custom elements placement tutorial

I want to create a unique target where I can place objects of different colors that respond in different ways when clicked directly on. Does anyone have any suggestions on how I can accomplish this? Perhaps there is a specific library that I could utilize ...

Issues arise when attempting to install global NPM packages using a basic CircleCI 2.0 setup

My Dockerfile is functioning properly and includes the following commands: FROM node:10 RUN npm set unsafe-perm true RUN npm install -g '@oresoftware/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a58184d6a1a041a041b1918 ...

E401 - Authentication failed, it appears that the authentication token provided is not valid

I recently switched from using the Azure Packages private NPM server back to the standard NPM registry, but I've encountered an issue that is preventing me from working. Despite my attempts to resolve it, the problem persists. Any assistance would be ...

Will my JavaScript function be triggered when the page is resized while printing?

I have a simple HTML layout where I am using the TextFill jQuery library to automatically adjust the text size based on available space. Everything looks good on screen, but when printed, it seems like the page is resized and the JavaScript needs to be re ...

What is the importance of setting up an HTTP server?

Can anyone explain why, in nodeJs programming with javascript, it is necessary to establish a server using the http module, even though one could simply utilize the fs module for reading, writing, and updating data stored in a json file? ...

Can we create a collection of Vue highcharts components in a library format?

I am in search of an answer, with hope that it lies here. I have used the following: "vite": "^2.7.13", "highcharts": "^9.3.3", "highcharts-vue": "^1.4.0" I aim to create a library of Vue compon ...

Implementing a Unique Approach to Showcase the Initial PDF Page as Cover through Django and JS

I would like to enhance my script so that when a user hovers over an object on the template, a PDF cover page can be set for each object. Current process: Currently, I am able to upload files in the .pdf and .epub formats for each object with additional ...

Having trouble adding global method using Plugin in Vue 3?

I have been working on creating a method that can generate local image URLs to be used in any template automatically. However, I encountered an issue while trying to develop a plugin that adds a global property. Plugin Implementation: // src/plugins/urlb ...

After the initial iteration, the .length function ceases to function properly when

A validation method is set up to check the length of a user input field. It functions properly on the initial try, but does not update if I go back and modify the field. $("#user").blur(function () { if ($("#user").val().length < 3) { $("#userval ...

What type of technology is typically utilized in creating functional platforms such as goDaddy, wix, and other web design websites?

I am currently working on a web development project that aims to allow users to edit webpages without needing any coding knowledge. Users with authorization will be able to modify not only the text but also various HTML tags on the page, similar to platfor ...

Customize the color of the label and underline in a Reactjs material-ui TextField when the field input

https://i.stack.imgur.com/oJ2ah.png <TextField id="standard-full-width" label="Password" style={{ margin: 8 }} fullWidth margin="normal" placeholder="*******" /> Struggling to understand how to modify the color of the label ...

Be mindful of potential missing dependencies when utilizing event listeners and states within useEffect

Whenever I utilize the addEventListener() method alongside trying to access some state within the useEffect, I consistently face the same issue. Adding the state as a dependency is not an option, as that would result in multiple event listeners being creat ...

The variable (form.onsubmit) remains unset even after assigning a value

function setFormOnSubmit(formName){ if(!formName) return; var form = document[formName]; form.onsubmit = function(){ console.log('This is the onsubmit function'); }; console.log('onsubmit successfully set ...

Prevent multiple submissions by disabling the Submit button in Magento after it has been clicked and

I am looking for a solution to disable the submit button or display a loading image over the form once the submission has been validated. I have tried various methods to disable the submit button after it is clicked, but these do not account for validation ...

Creating a fluid side navigation bar in reactjs

Can someone please help me with the following code issue? I am encountering an error related to the script tag when running it in ReactJS, although it works fine in a simple HTML file. Upon starting npm, an error is displayed pointing to line number which ...