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

Viewed 3381

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:

enter image description here

What am I doing wrong?

5 Answers

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:

  1. in package.json changed peerDependencies versions to *
  2. npm publish

in the project directory:

  1. rm -Rf node_modules && yarn install
  2. yarn add your-package-name

now everything works like a charm

Related