React-native, “Native module cannot be null”

前端 未结 12 1107
星月不相逢
星月不相逢 2020-12-09 14:42

I just upgrade React-native from 0.28 to 0.30, and get this error:

\"Native module cannot be null\".

The problem seem to be with the line/package:

相关标签:
12条回答
  • 2020-12-09 14:55

    remove react-native-push-notification in node_modules

    run npm install react-native-push-notification@3.1.3

    0 讨论(0)
  • 2020-12-09 14:56

    My issue had the same symptoms but a much different root cause. I had two React Native projects open in two different instances of Xcode. My Metro bundler was still running from Project A and causing problems running Project B in the simulator.

    The fix: close the old terminal window spawned by Xcode that had the Metro Bundler running and re-run the project.

    0 讨论(0)
  • 2020-12-09 14:57

    In my case, running a $ pod install inside /ios directory did the trick!

    0 讨论(0)
  • 2020-12-09 14:57
    1. npm i @react-native-community/push-notification-ios
    2. cd ios && pod install
    3. react-native unlink @react-native-community/push-notification-ios

    That's how I solved it after struggling for hours.

    0 讨论(0)
  • 2020-12-09 14:58

    Sometimes it can be an issue of when you install different libraries through npm. All need to do is: go to the project's ios folder, and run pod install. This will help to avoid this error, this is one of the reasons also.

    0 讨论(0)
  • 2020-12-09 15:02

    Sometime, if you had another react-native packager already running for a different app. You may see this problem.

    Especially if the react-native versions are same and the previously started app requires a native module which is not available in the current app.

    In these cases, you can kill the react packager terminal and restart it and problem should go away.

    Also if it is the same app and you just upgraded. Make sure that it is linked properly. If not call react-native link again.

    0 讨论(0)
提交回复
热议问题