Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using the latest firebase version #267

Closed
crunchytoast opened this issue May 10, 2022 · 14 comments
Closed

Issue when using the latest firebase version #267

crunchytoast opened this issue May 10, 2022 · 14 comments

Comments

@crunchytoast
Copy link

Android Bundling failed 4326ms While trying to resolve module idbfrom fileD:###\node_modules@firebase\app\dist\esm\index.esm2017.js, the package D:###\node_modules\idb\package.jsonwas successfully found. However, this package itself specifies amain module field that could not be resolved (D:###\node_modules\idb\build\index.cjs. Indeed, none of these files exist:

To reproduce, initialize an expo project, npm install the latest firebase version, and import any module from firebase in the App.js file.

@jakearchibald
Copy link
Owner

I'm not familiar with Firebase. Can you give me step by step instructions. I don't know what an 'expo project' is.

@crunchytoast
Copy link
Author

ok I'm sorry, I'll write out the full details to recreate this issue...

expo is just a helper to make react-native apps, and firebase is a popular no-sql database hosting service

npm install --global expo-cli

then clone the repo I just shared with you called testfirebase

to start, you run expo install,
then expo start

It should show the error...

@crunchytoast
Copy link
Author

I have a hunch it's more of a firebase error... since they had stopped using idb as a dependency, then just recently started using it again and have run into this issue. So I'm not sure which part of the equation has changed.

@jakearchibald
Copy link
Owner

Yeah, I think so. Can you file an issue with them and link to it here?

@crunchytoast
Copy link
Author

firebase/firebase-js-sdk#6253

Here's a link to an existing issue there, where people are suggesting it's a problem with metro recognizing .cjs files. Seems to be an error merry-go-round...

If this is the case, the metro is working on a fix, and has a PR already in the works...

facebook/metro#770

@SohelIslamImran
Copy link

Same issue
image

@crunchytoast
Copy link
Author

If you want a workaround, you can either downgrade your firebase version for now... or add a cjs reference in your metro.config file @SohelIslamImran

@SohelIslamImran
Copy link

@crunchytoast Thank you.
Resolved.

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;

image

@skinsation89
Copy link

Adding the cjs reference in metro.config.js DID NOT WORK for me. Still receiving the same failed to resolve idb error. I tried all variations of it with sourceExt and still didn't work.

@crunchytoast
Copy link
Author

If adding the cjs reference doesn't work, then just roll back firebase

npm uninstall firebase
npm install firebase@9.6.11

@crunchytoast
Copy link
Author

This isn't an idb issue... it's an error in the metro bundler not recognizing cjs files, combined with idb being added as a dependency for the latest firebase version.

@skinsation89
Copy link

skinsation89 commented May 19, 2022 via email

@mfellner
Copy link

Just commenting here for folks that may still run into the same issue as I do:

Error thrown when reading from storage. Original error: (0 , _idb.openDB) is not a function. (app/storage-get).

firebase/firebase-js-sdk#6253 (comment)

@crunchytoast
Copy link
Author

crunchytoast commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants