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
Related
I'm new to react native and have some experience with using regular React and am trying to get react native navigation setup but am running into the following error when following the docs. I've tried starting from scratch and reinstalling everything as I have no clue what this error means:
Invariant Violation: RNCSafeAreaProvider was not found in the UIManager
any advice on how to fix this would be appreciated.
I recently encountered this issue. I solved it by running yarn add react-native-safe-area-context.
for anyone who comes across this error - the way I did the installation must have been wrong as starting with a fresh project and doing the commands in this order - I did not come across the same problem:
expo init 'Project-name'
cd 'Project-name'
npm run android
npm install #react-navigation/native
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context #react-native-community/masked-view
npm install #react-navigation/stack
I solved this issue by run these commands
npm install react-native-safe-area-context
pod install
As an additionnal case: I went into this error when using react-navigation in an Expo Bare workflow, also following guide for react-navigation.
I simply fixed this with:
projectRoot $ cd ios
projectRoot/ios $ pod install
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.
I've just updated some Node modules in a React react project, but now when I go to localhost:3000 I get a Failed to compile error because ./node_modules/jss-default-unit/lib/index.js was not found:
The packages I've upgraded are Material UI and react-scripts, as seen from a git diff of package.json:
How can I resolve this issue?
(This issue, https://github.com/cssinjs/react-jss/issues/146, describes a similar issue caused by Babel running on node_modules, but I wasn't able to find a webpack.config.js in node_modules/babel-loader to modify).
I resolved this by running npm install jss-default-unit and restarting the server with npm start.
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.
I created a native module and created another project to test it locally.
Here are my steps:
cd <Testing project>
npm install ../<Module project>
react-native link <module name>
react-native run-android
Then I got following error:
error: bundling failed: Error: Unable to resolve module `react-native-helloworld` from `G:\Test\App.js`: Module `react-native-helloworld` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
I've searched StackOverflow for the issue, but there's no workable solution. The suggested solution 'clear the cache and reset everything' cannot work.
However, the module can work if I publish it to https://www.npmjs.com/ and then install it via npm install <module name>.
The only difference is the installing way.
I got a similar error complaining about how it could not find 'path' from where ever it was looking for. In the end I figured out that the issue was completely unrelated.The following auto import was accidentally added to my code (probably when I was creating a style using 'textTransform')
import { transform } from "#babel/core";
Once I noticed that and removed it, the project was buildable. It might help to check recent changes in your code to see if something similar got added.
Chances are that you're accidentaly symlinking your library inside node_modules when you use npm, instead of using npm you can use yarn
yarn add file:../<module_project>