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

Expo SDK 43 Error: @react-native-community/netinfo: NativeModule.RNCNetInfo is null. #1600

Closed
SudoGetBeer opened this issue Nov 26, 2021 · 15 comments

Comments

@SudoGetBeer
Copy link

Describe the bug

If I use import Bugsnag from '@bugsnag/expo' I get this error log and the app crashes:

Error: @react-native-community/netinfo: NativeModule.RNCNetInfo is null. To fix this issue try these steps:

• Run `react-native link @react-native-community/netinfo` in the project root.
• Rebuild and re-run the app.
• If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
• Check that the library was linked correctly when you used the link command by running through the manual installation instructions in the README.
* If you are getting this error while unit testing you need to mock the native module. Follow the guide in the README.

If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-netinfo
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:204:6 in guardedLoadModule
at http://192.168.178.52:8081/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:130574:3 in global code

RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
at node_modules/react-native/Libraries/Utilities/RCTLog.js:34:8 in logIfNoNativeHook

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError

Environment

  • Bugsnag version: tried 7.14 and 7.13
  • Device (e.g. iphonex): iphone 11
@johnkiely1
Copy link
Member

Hi @SudoGetBeer

Are you able to share some more details around your project? Is this an Expo managed workflow project?
Did you install bugsnag via the cli or manually? And which version of @bugsnag/expo are you using?

Have you tried the suggestions given in that error message?

@johnkiely1 johnkiely1 added the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Nov 26, 2021
@SudoGetBeer
Copy link
Author

SudoGetBeer commented Nov 26, 2021

Are you able to share some more details around your project?

It worked and then I upgraded to SDK 43 and building with EAS.

Is this an Expo managed workflow project?

Yes the managed workflow.

Did you install bugsnag via the cli or manually?

Tried both the cli and manual.

And which version of @bugsnag/expo are you using?

Bugsnag version: tried 7.14 and 7.13

Have you tried the suggestions given in that error message?

Yes but it just says:

react-native link @react-native-community/netinfo
warn Calling react-native link [packageName] is deprecated in favor of autolinking. It will be removed in the next major release.
Autolinking documentation: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
error Unknown dependency. Make sure that the package you are trying to link is already installed in your "node_modules" and present in your "package.json" dependencies.
info Run CLI with --verbose flag for more details.

@johnkiely1
Copy link
Member

Hi @SudoGetBeer ,

I've managed to reproduce what you are seeing.
If you try the following it should work:

npm i @react-native-community/[email protected]
and then
react-native link @react-native-community/netinfo

Let me know if this works for you.

@SudoGetBeer
Copy link
Author

The command works now.
But the app still crashes until I remove the Bugsnag import.

@SudoGetBeer
Copy link
Author

@johnkiely1 any other ideas?

@stephenb
Copy link

stephenb commented Dec 1, 2021

I'm getting the same issue.

@johnkiely1
Copy link
Member

johnkiely1 commented Dec 3, 2021

@SudoGetBeer @stephenb

I wonder if this is related to using EAS build? EAS build is not something we have tested with so its plausible this is causing the issue. Would it be possible to test running this with npm run ios or expo run:ios to see if we can narrow it down to be EAS build related?

@SudoGetBeer
Copy link
Author

@johnkiely1
I had the same error when using expo start --dev-client. If that helps.
npm run ios or expo run:ios dont work for me. But I build a new testflight version with expo build:ios and will test that

@SudoGetBeer
Copy link
Author

It seems it is the eas. With the old build the app don't crash on startup

@stephenb
Copy link

stephenb commented Dec 3, 2021

@johnkiely1 Yes, I am in the process of switching to using EAS build. I'm assuming bugsnag's expo client had been assuming netinfo was natively available, but that has changed with EAS... but, I'm still getting up to speed on how this all works so not too certain.

@johnkiely1
Copy link
Member

I did come across this, https://forums.expo.dev/t/eas-build-does-not-install-dependencies-defined-in-other-node-modules/59178 which seems related. There is also this suggestion here which might help. Perhaps there is a way to ensure the netinfo dependency is loaded correctly via some EAS build config. I'm not sure what that would be as I'm not at all familiar with EAS build as it is not something that is officially supported by Bugsnag. We have a roadmap item to look into supporting it the future but we don't have an estimate for when this might be as yet.

@mattdyoung mattdyoung removed the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Dec 17, 2021
@mattdyoung
Copy link
Contributor

Closing, as we believe this is a build issue related to EAS.

We plan to consider official support for Expo EAS Build in the future.

@stephenb
Copy link

OK, and just to update the thread, I did fix my build by manually adding the netinfo dependency. Perhaps best-practice wrt EAS Build will be for 3rd party libs to specify these dependencies, but I'm not totally sure. Expo is moving towards EAS Build being the primary build process though, as the old build process will be phased out.

@PavleNeskovic
Copy link

If anyone still has the issue using dev client, try running npx expo prebuild and then eas build --platform all. That was the issue on my end.

@ravishukla21
Copy link

ravishukla21 commented Sep 3, 2024

It works on expo go but on running on development build it gives error

ERROR Error: @react-native-community/netinfo: NativeModule.RNCNetInfo is null. To fix this issue try these steps:

• Run react-native link @react-native-community/netinfo in the project root.
• Rebuild and re-run the app.
• If you are using CocoaPods on iOS, run pod install in the ios directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
• Check that the library was linked correctly when you used the link command by running through the manual installation instructions in the README.

  • If you are getting this error while unit testing you need to mock the native module. Follow the guide in the README.

If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-netinfo, js engine: hermes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants