React Native Firebase Invalid Package.json Exports Fix: Metro NativeModule Does Not Exist
Fix the React Native Firebase "invalid package.json exports" Metro error and "NativeModule does not exist in NativeModules" crash. Step-by-step solutions for @react-native-firebase, Expo, Metro resolver, and package.json exports field issues. Updated for 2026.
On this page
While building a React Native or Expo app with @react-native-firebase, you may encounter Metro bundler errors related to invalid package.json exports or a runtime crash saying a NativeModule does not exist. These errors usually appear after upgrading React Native, updating the Firebase SDK, installing a new Firebase module, switching from Expo Go to a development build, or updating Metro bundler. The root cause is almost always a conflict between the package.json `exports` field in Firebase packages and how Metro resolves modules.
The Error
You may also see variations like `Package path . is not exported from package`, `Cannot find module @react-native-firebase/app/lib/module/index`, or `NativeModule.RNFBAuthModule is null` at runtime even when the build succeeds.
What Causes This Error
The package.json `exports` field is a newer Node.js feature that controls which files inside a package can be imported and how they resolve. React Native Firebase added `exports` maps in recent versions to support ESM, but Metro bundler does not fully support the `exports` field in all configurations. When Metro encounters an `exports` map it cannot resolve, it throws an error instead of falling back to the `main` or `react-native` field.
- Metro bundler version does not fully support package.json exports field
- @react-native-firebase packages updated to a version with exports maps
- React Native or Expo upgraded but Metro config not updated
- Missing or outdated metro.config.js resolver settings
- Firebase native modules not linked (NativeModule does not exist at runtime)
- Using Expo Go instead of a development build with native Firebase modules
- Conflicting package versions between @react-native-firebase/app and other Firebase modules
- Yarn or npm hoisting placing Firebase packages in unexpected locations
Fix 1: Enable unstable_enablePackageExports in Metro Config
The most common fix is telling Metro to understand the `exports` field in package.json. Add the `unstable_enablePackageExports` flag to your metro.config.js resolver. This lets Metro resolve packages using their exports map instead of throwing an error.
Expo Metro Config Version
After adding this flag, stop Metro completely, clear the cache, and restart.
Fix 2: Set unstable_conditionNames for React Native
Even with `unstable_enablePackageExports` enabled, Metro may pick the wrong export condition. Firebase packages export different entry points for `import`, `require`, `react-native`, and `default`. You need to tell Metro which conditions to use and in what priority order.
The order matters. Putting `react-native` first ensures Metro uses the React Native specific entry point when available. The `require` condition handles CommonJS imports, and `default` is the fallback.
Fix 3: Patch the Firebase Package.json Exports Field
If enabling exports support in Metro causes other packages to break, you can patch the specific Firebase package to remove or fix the exports field. Use patch-package to make the change survive npm install.
Open the Firebase package.json that is causing the error and either remove the `exports` field entirely or fix the subpath that Metro cannot resolve.
After editing, create the patch and add the postinstall script.
Fix 4: Align All Firebase Package Versions
React Native Firebase requires all @react-native-firebase packages to be on the same version. If @react-native-firebase/app is v21.x but @react-native-firebase/auth is v20.x, you will get module resolution errors, missing exports, or NativeModule crashes.
Fix 5: NativeModule Does Not Exist (Runtime Crash)
If the Metro build succeeds but the app crashes at runtime with `NativeModule.RNFBAppModule does not exist in NativeModules` or similar Firebase NativeModule errors, the native Firebase modules are not linked to your app. This is a separate issue from the exports error.
- If using Expo Go: Firebase requires native code, you must switch to a development build with expo-dev-client
- If using bare React Native: run pod install on iOS and rebuild, Firebase auto-links but needs a native rebuild
- If using Expo prebuild: run npx expo prebuild --clean to regenerate native projects with Firebase native modules
- Check that GoogleService-Info.plist (iOS) and google-services.json (Android) are in the correct locations
- Make sure @react-native-firebase/app is imported before any other Firebase module
Expo Development Build Setup
Fix 6: Update Metro Bundler
Older Metro versions have worse support for the package.json exports field. If you are on Metro 0.76 or older, updating to Metro 0.80 or above significantly improves exports resolution. Check your Metro version and upgrade if needed.
Fix 7: Clear All Caches and Rebuild
After making any of the above changes, you must clear all caches. Metro aggressively caches module resolutions, so even after fixing metro.config.js, the old broken resolution may be cached.
Expo Full Rebuild
Quick Diagnosis Checklist
- Check if metro.config.js has unstable_enablePackageExports set to true
- Check if unstable_conditionNames includes react-native, require, and default
- Run npm ls @react-native-firebase/app and check all Firebase packages are on the same version
- Check Metro version with npx metro --version
- If NativeModule error at runtime: are you using Expo Go instead of a development build?
- Is @react-native-firebase/app imported before all other Firebase modules?
- Are GoogleService-Info.plist and google-services.json in the correct locations?
- Did you run pod install on iOS after installing Firebase packages?
- Clear Metro cache with --reset-cache after any config change
- If patch-package is used: check that patches are applied after npm install
Final Working Metro Config
Official-Style Error Explanation
The React Native Firebase invalid package.json exports error occurs when Metro bundler cannot resolve module paths through the `exports` field in @react-native-firebase package.json files. Metro historically used the `main` and `react-native` fields for module resolution, but newer Firebase versions added `exports` maps for ESM compatibility. When Metro encounters an exports map it does not support or cannot resolve, the build fails with `Package subpath is not defined by exports` or `Invalid package.json exports`. The fix is to enable `unstable_enablePackageExports` and set `unstable_conditionNames` in metro.config.js so Metro resolves Firebase modules through the exports field correctly. The separate runtime error where NativeModule does not exist happens when Firebase native code is not compiled into the app binary, usually because the project uses Expo Go instead of a development build, or because pod install was not run after installing Firebase packages.
FAQ
What does invalid package.json exports mean in React Native?
It means Metro bundler is trying to resolve a module through the package.json exports field but cannot find the requested subpath. The exports field controls which files inside a package can be imported. When Metro does not support the exports map format, it throws this error instead of falling back to the main field.
Why does this error only happen with Firebase packages?
React Native Firebase added exports maps to their package.json files in recent versions for ESM compatibility. Most other React Native packages still use the older main and react-native fields that Metro handles without issues. Firebase was one of the first major RN packages to adopt the exports field, which exposed the Metro compatibility gap.
Will unstable_enablePackageExports break other packages?
It can in some cases. Enabling exports support changes how Metro resolves all packages, not just Firebase. If another package has a broken or incomplete exports map, it may start failing. If this happens, add unstable_conditionNames to control which export conditions Metro uses, or patch the specific broken package with patch-package.
Why does NativeModule RNFBAppModule not exist even after fixing the Metro error?
The Metro exports error and the NativeModule error are two separate issues. The Metro error is a build-time module resolution problem. The NativeModule error is a runtime problem meaning Firebase native code is not linked to your app. This happens when using Expo Go (which cannot include custom native modules), when pod install was not run on iOS, or when the app was not rebuilt after installing Firebase.
Can I use React Native Firebase with Expo Go?
No. React Native Firebase requires native code that Expo Go does not include. You must use a development build with expo-dev-client. Install expo-dev-client, run npx expo prebuild --clean, then build with npx expo run:ios or npx expo run:android.
Do all @react-native-firebase packages need to be the same version?
Yes. All @react-native-firebase packages must be on the same major and minor version. Mixing versions like @react-native-firebase/app v21.x with @react-native-firebase/auth v20.x can cause exports resolution errors, missing native modules, and runtime crashes. Always update all Firebase packages together.
Shahmeer Rizwan
Full-Stack Developer