Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example App Crashing After Adding Dependencies to Module #42

Open
aelitneg opened this issue Apr 6, 2020 · 3 comments
Open

Example App Crashing After Adding Dependencies to Module #42

aelitneg opened this issue Apr 6, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@aelitneg
Copy link

aelitneg commented Apr 6, 2020

Situation:

  • I used react-nativemodule-init to create a library, with a view, and an example app. Everything is working properly.
  • I run yarn add prop-types in the library root (not example)
  • Yarn installs successfully, I restart Metro Bundler. The build completes successfully and launches on the iOS simulator.

Issue:
When the app launches on the iOS simulator, there are 3 errors in the Javascript console:

Invariant Violation: Module HMRClient is not a registered callable module (calling setup)

Invariant Violation: Module RCTLog is not a registered callable module (calling logIfNoNativeHook)

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

Once I start throwing these errors, I cannot get the example app to run again.

I've cleared out Metro Bundler's cache. I've cleaned build folders. I've removed node_modules folders and installed fresh packages. I've removed Pods and installed fresh pods. I've restarted m machine.

The ONLY way I can get it to run again is by pushing my branch to GitHub, removing the directory from my machine, cloning from GitHub, running yarn and pod install for the example folders.

The fix leads me to believe that something must be cached that I'm not clearing out. Any help would be greatly appreciated!

@brodycj brodycj added the bug Something isn't working label Apr 6, 2020
@brodycj
Copy link
Owner

brodycj commented Apr 6, 2020

Thanks @agentile1990 for the detailed reproduction. I was able to reproduce at least one of your errors. The quick workaround is to remove node_modules from the library root (not from the example) and restart the Metro Bundler. (I think I did redo react-native run-ios as well.) And you may not even have to restart the Metro Bundler, I am not sure.

Another idea for you may be to add prop-types to peerDependencies and devDependencies in the library root. In this case, you would theoretically have to add prop-types to the app as well but it may actually work without it since prop-types seems to be pulled in by both react and react-native anyway. Probably not a very good idea in practice but just wanted to throw it out there.

I may need some time to further investigate this one and see if it affects create-react-native-module as well or not. This will need to be documented at the very least.

Thanks again!

@brodycj
Copy link
Owner

brodycj commented Apr 6, 2020

FYI I reproduced the same issue on Android, with non-view library. I tried removing node_modules from the library root and restarting the Metro bundler, worked after I reinstalled the app.

I will try this on create-react-native-module next. (create-react-native-module works a little differently since it does yarn add file:../ instead of yarn add link:../ in the example app and adds a workaround postinstall script. I am planning to update create-react-native-module to work the same way is this one, to do yarn add link:../ in the example, but would like to understand this issue better first.)

@cunneen
Copy link

cunneen commented Jan 15, 2021

Thanks for reporting this @agentile1990 . I've encountered the same issue, I didn't even realise it was this module until I went to create a simple reproduction and saw the notice:

⚠ KNOWN ISSUE with adding dependencies to the library root
ℹ see https://github.com/brodybits/create-react-native-module/issues/308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants