Home > Enterprise >  firebase-js-sdk v9 doesn't work with react native? Error: While trying to resolve module `idb`
firebase-js-sdk v9 doesn't work with react native? Error: While trying to resolve module `idb`

Time:05-12

trying to use firebase-js-sdk v9 for my react-native project but app build fails due to the following idb related error. Does anyone know anything about this issue?

enter image description here

CodePudding user response:

I downgraded firebase version to v9.6.1 which works fine.

CodePudding user response:

If you are using expo, to resolve this issue, create a metro.config.js file in the project root. In the file add the file extension cjs. details

const { getDefaultConfig } = require("@expo/metro-config");

const defaultConfig = getDefaultConfig(__dirname);

defaultConfig.resolver.assetExts.push("cjs");

module.exports = defaultConfig;

ScreenShot

React Native cli

const { getDefaultConfig } = require("metro-config");
const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues();
exports.resolver = {
  ...defaultResolver,
  sourceExts: [
    ...defaultResolver.sourceExts,
    "cjs",
  ],
};
  • Related