Open permafrost06 opened 2 years ago
Try installing the @firebase/app
and @firebase/firestore
packages, then set your externals to externals: ['@firebase/app', '@firebase/firestore/lite']
. Then, import from those packages like so:
import { initializeApp } from "@firebase/app";
import {
getFirestore,
getDoc,
updateDoc
} from '@firebase/firestore/lite';
Trying to import firestore using import { initializeFirestore } from "firebase/firestore/lite"
or import { initializeFirestore } from "@firebase/firestore/lite"
fails with error:
ERROR Failed to compile with 1 errors 1:34:57 PM
This dependency was not found:
* firebase/firestore/lite in ./src/background.js
To install it, you can run: npm install --save firebase/firestore/lite
Can you share a repo that demonstrates the error? Using that import worked fine for me so I'm not sure why it won't work for you.
Check out this repo: vue-electron-firestore
Running npm run electron:serve
results in an error window:
I'm trying to use the compat packages using the docs on this page.
I'm getting the same error "fetch is not defined" and installing the @firebase/app
and @firebase/firestore
packages doesn't seem to help, I'm guessing those don't include the compat packages. Apparently @firebase/compat/app
doesn't exist.
I'm curious as to why the firebase docs suggest importing from firebase/app
and not @firebase/app
and what the difference is?
Describe the bug I'm trying to use firebase firestore with
background.js
but keep getting error sayingfetch is not defined
. The firebase js SDK is supposed to work in both web and node.js. In this case though, it seems firebase does not recognize that it's running on node.js and instead tries to run as it does on web. But it fails since node.js does not have web APIs such asfetch
. I have tested that firebase firestore runs as intended in a standalone node.js script. I have tried putting firebase and firestore in theexternals
but it didn't help. (Changing some things show a different errorheaders is not defined
in a error window)To Reproduce
vue add electron-builder
npm install firebase
background.js
according to the firebase docs then call a firestore function likegetDoc()
npm run electron:serve
fetch is not defined
Expected behavior Expect firestore to behave normally and fetch a doc from the server.
Environment (please complete the following information):
terminal output from running
vue info
:Additional context From the research I've done on this, it seems there might be an issue with webpack configuration. But adding
firebase
,firebase\firestore
, andfirebase\firestore\lite
or@firebase\firestore
and@firebase\firestore\lite
tovue.config.js
'spluginOptions.electronBuilder.externals
hasn't changed anything.