Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: react-native-permissions: NativeModule.RNPermissions is null

I am facing this error while starting react native android app. Error: react-native-permissions: NativeModule.RNPermissions is null. To fix this issue try these steps: • If you are using CocoaPods on iOS, run pod installin theios directory and then clean, rebuild and re-run the app. You may also need to re-open Xcode to get the new pods. • If you are getting this error while unit testing you need to mock the native module. You can use this to get started: https://github.com/react-native-community/react-native-permissions/blob/master/mock.js If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-permissions

I have followed the steps mentioned in the error body no luck. steps I followed:

  1. pod install
  2. clean and rebuild the app
  3. npx react-native-clean-project

My pod file:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
# pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
platform :ios, '11.0'

target 'BayQi' do
  pod 'react-native-contacts', :path => '../node_modules/react-native-contacts'
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])



  target 'BayQiTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  # use_flipper!
  # post_install do |installer|
  #   flipper_post_install(installer)
  # end
end

target 'BayQi-tvOS' do
  # Pods for BayQi-tvOS

  target 'BayQi-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end
like image 790
nouman-stackone Avatar asked May 06 '26 17:05

nouman-stackone


1 Answers

This is because react-native-qrcode-scanner uses the old version react-native-permissions. One of the typical solutions for such a case is to override dependencies. Override the react-native-permissions dependency for react-native-qrcode-scanner. For npm we need to use overrides, and for resolutions for yarn.

So for this code works just delete node_modules folder, yarn.lock file, and add this code to package.json

  "resolutions": {
    "react-native-permissions": "^3.8.0"
  },
  "overrides": {
    "react-native-qrcode-scanner": {
      "react-native-permissions": "^3.8.0"
    }
  },

Than run yarn or npm imstall. My package.json looks like this:

  "dependencies": {
...
    "react": "18.2.0",
    "react-native": "0.71.4",
...
    "react-native-permissions": "^3.8.0",
    "react-native-qrcode-scanner": "^1.5.5",
...
  },
...
  "resolutions": {
    "react-native-permissions": "^3.8.0"
  },
  "overrides": {
    "react-native-qrcode-scanner": {
      "react-native-permissions": "^3.8.0"
    }
  },

With yarn this package.json works well.

like image 81
Zakharov Dmitry Avatar answered May 08 '26 20:05

Zakharov Dmitry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!