0

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

Otani Shuzo
  • 1,118
  • 1
  • 11
  • 22
  • 2
    I’m voting to close this question because let's avoid just pasting screenshots of text. Prefer to actually enter in the text so that others can find this through search engines. Do the redaction in the text instead of Microsoft Paint. – Josh May 10 '22 at 06:35
  • right, totally agree! I downgraded firebase to v9.6.1 which works fine. – Otani Shuzo May 10 '22 at 09:28
  • It’s a good idea to include code, errors and and structures as *text*, not links and images. That way, if they are needed in an answer, they can be copied and pasted. Also, images are not searchable which may prevent future readers from locating the question. See [images and links are evil](http://idownvotedbecau.se/imageofcode) and take a look at [No Images Please](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) – Jay May 13 '22 at 18:26

4 Answers4

2

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",
  ],
};
Sohel Islam Imran
  • 1,631
  • 6
  • 10
  • I added this as you said and nothing changed. Is it possible that the problem is in something else? – Listopad02 Jun 15 '22 at 11:28
  • @Listopad02 Are you using expo? You can clear the cache by `expo start --android --clear` or try to delete `node_modules` and reinstall packages. It should work. – Sohel Islam Imran Jun 15 '22 at 16:51
  • This worked for many people, I believe maybe something wrong with your setup. https://stackoverflow.com/questions/72179070/react-native-bundling-failure-error-message-while-trying-to-resolve-module-i/72201722#72201722 – Sohel Islam Imran Jun 15 '22 at 16:53
  • 1
    I found a mistake, i was making bad queries. Now it is OK. Thanks for your answer, it really helped me – Listopad02 Jun 16 '22 at 21:10
  • @Listopad02 You are welcome. You can vote for this answer if this helps you. – Sohel Islam Imran Jun 17 '22 at 20:05
2

I just added the following code to metro.config.js file. Im using Firebase v9.8.1 and React Native CLI

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
  //added this
  resolver: {
    sourceExts: ['jsx', 'js', 'ts', 'tsx', 'cjs'],
  },
};
EdEd
  • 331
  • 2
  • 3
1

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

Otani Shuzo
  • 1,118
  • 1
  • 11
  • 22
0

Had the same problem. Downgrading to version 9.6.11 solved it for me.

npm uninstall firebase
npm install firebase@9.6.11