Module HMRClient is not a registered callable module (calling enable) in Linux - reactjs

First When I created the app with react-native init project1 .
I was getting an error as below
Unable to load script from assets index.android.bundle on windows
Later I solved this issue by running following commands Stackoverflow link
mkdir android/app/src/main/assets
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android
But later I am getting an error like this and not able to solve, Module HMRClient is not a registered callable module (calling enable)

This is the common occurred problem, but there will not be some problem in bundling the app, Just follow some common steps and it worked for me.
Delete node_module folder and install npm
rm -rf node_modules && npm install
cd android && ./gradlew clean
then cd .. && react-native run-android

If you're developing a native module and your npm link'd folder contains a node_modules directory, this can also produce the error.
To correct for this case, you can delete the node_modules directory, re-install your project in the linked folder and use react-native start --reset-cache.

Disable hot reloading, it will work fine

This issue occurs if we enabled the production mode from dev setting by unchecking "JS Dev Mode" and then try to enable the hot reload.
Enable JS Dev Mode again will work.

Related

Invariant Violation: no callback found with cbID for module<unknown>

I have created yarn package with common components, services, utils, etc. for my project. Then I have created index.ts file in src folder, where I've exported all components. Then I've built the package, added to my project. Then if I import a component from the package after starting the app in a real device or in an emulator, it's all OK. But if I import component first and then start app with react-native run-android (or -ios), I get a lot of errors Invariant Violation: no callback found with cbID for module<unknown> in loop:
What am I doing wrong?
Just fixed it. You need to make sure the react-native version is compatible with the react-native version of your dependencies.
For example: your project: react-native: 0.65, but your dependency: 0.64. You will get this error.
In my case this was due to a mismatch between the JS react-native version and the native version.
Near the top of the logs was the message below. Running watchman watch-del-all && react-native start --reset-cache as suggested in the log message fixed the issue.
2021-12-13 12:09:04.781041-0800 example[32395:987769] [javascript] React Native version mismatch.
JavaScript version: 0.63.4
Native version: 0.66.4
Make sure that you have rebuilt the native code. If the problem persists try clearing the Watchman and packager caches with `watchman watch-del-all && react-native start --reset-cache`.
2021-12-13 12:09:04.856943-0800 example[32395:987769] [javascript] Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
2021-12-13 12:09:04.859616-0800 example[32395:987758] [connection] nw_socket_handle_socket_event [C6.1:1] Socket SO_ERROR [61: Connection refused]
Remove node_modules and try again. It resolved the issue for me
rm -rf node_modules
npm install --save
I looked into this answer here, and found that this actually works for RN navigation 6 I fixed it in my yarn workspace configuration as per the answer. In my package.json I added at the end.
Then I deleted the node_modules folder
And then rebuild the project and the error was gone.
"nohoist": [ "**/*/**" ]
yep, faced the same issue and resolved it with changing peerDependencies in my library. what i did:
in the library directory:
in package.json changed peerDependencies versions to *
npm publish
in the project directory:
rm -Rf node_modules && yarn install
yarn add your-package-name
now everything works like a charm

Unhandled JS Exception: Requiring unknown module "104"

I have installed React Native Highcharts but while importing the module:
import HighchartsReactNative from '#highcharts/highcharts-react-native';
Getting error Unhandled JS Exception: Requiring unknown module "104". If you are sure the module exists, try restarting Metro. You may also want ti run 'Yarn' or 'npm install' importing the module I got the above error.
I have already restarted the Metro bundler and restarted many times but did not worked.
Ensure the module is installed by checking the folder node_modules/#highcharts/highcharts-react-native
If it is missing, install it with yarn add #highcharts/highcharts-react-native or npm install --save #highcharts/highcharts-react-native
Clear metro cache with watchman watch-del-all and rm -rf $TMPDIR/metro-bundler-cache-*
Restart the bundler resetting the cache with yarn start --reset-cache or npm run start --reset-cache
Reload the bundle in your app (shake and press Restart on the menu)
You could try to clear Metro cache. Please take a look to this gist.
Hope this helps.

Build failed for task ':app:bundleReleaseJsAndAssets' in react native

At the time of release build getting error in react native
In your scenario I think you haven't made a js bundle so please make a bundle first by using command from your project root folder
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
After that move in to your project's android directory using cd android
Before make release build make sure to clean your gradle using ./gradlew clean
And finally run this command ./gradlew assembleRelease -x bundleReleaseJsAndAssets
I have posted a full answer on this issue on here

How to fix: Error: ENOENT: no such file or directory 'src/node_modules/native-base/Fonts'

I was following up a tutorial which used expo and needed the fonts for native code, but I'm not using expo thus I don't need those fonts. I removed the code that was using them (nothing that would affect the other parts of the app), and now it gives me this hideous error that it says is located on my source folder "src/navigation/node_modules/native-base/Fonts", the node modules are not even located on the src.
Bear in mind that I'm new to react native, any help would be appreciated.
Terminal output:
bundling failed: Error: ENOENT: no such file or directory, scandir
'/Users/relativity/Documents/ReactNative-Projects/test/src/navigation/node_modules/native-base/Fonts'
Try npm install in your project directory, perhaps you deleted something that wasn't meant to be deleted.
Open terminal and navigate to your project directory and run npm install after it is done run react-native run-android or react-native run-ios
It looks like some default fonts are missing.
npm rebuild native-base is the official solution. Deleting your node_modules and running npm install will also do the trick. If this doesn't work try clearing cache, deleting node_modules and installing packages.

React Native app created with init not working if i moved from one folder to other

Action: Initially my app use to work as expected but after Moving react native app created on desktop to a different folder i am getting below error
Error: Runtime is not ready for debugging on simulator while running app from vscode using command react-native run-ios
Tried: npm start as well
You can try deleting your android, ios and node modules folder and run the following
1.> npm install // to get dependecies loaded
2.> react-native upgrade // to create ios and android folder
3.> react-native link // to link the libraries
4.> react-native run-android (or) > react-native run-ios
For react-native version 0.60 or more
1.> npm install // to get dependecies loaded
2.> react-native upgrade --legacy // to create ios and android folder
3.> react-native link // to link the libraries
4.> react-native run-android (or) > react-native run-ios
Possible dupe of Moving Create React App folder breaks working app
In case above didn't help, deleting the ios/build folder and running again worked for me.
i.e. from your new root folder
rm -r ios/build
npx react-native run-ios
Per answer in https://github.com/facebook/react-native/issues/18793

Resources