Exports is not defined while using firestore

Viewed 193

I am getting this error while using firestore in typescript -

exports is not defined
ReferenceError: exports is not defined
    at eval (/node_modules/@firebase/firestore/dist/index.node.cjs.js?v=470e9090:5:23)
    at instantiateModule (C:\Users\ADMIN\Desktop\game-store\node_modules\vite\dist\node\chunks\dep-713b45e1.js:66472:15)

I am using it with svelte kit.

I am following the docs on the firebase website and I think this error comes in getFirestore in onMount. this error happens sometimes and sometimes not.

Please help how to solve it!

1 Answers

I suspect there is a possible solution to your issue in a GitHub discussion I’ve found. They talk about incompatibility between firebase and svelte, but at the end someone commented this was an error caused by the imports. The comment is:

...Looks like when you import "@firebase/app" instead of "firebase/app" it works. Seems like Vite is unable to resolve "firebase/app" to "@firebase/app" because the firebase team said it actually points to "@firebase/app"...

Related