I'm trying to connect to my local emulator and i'm getting an error.
My firebase.js
file reads like:
const hostname = window.location.hostname;
const app =
hostname === "localhost"
? initializeApp({
apiKey: process.env.REACT_APP_APIKEY,
authDomain: process.env.REACT_APP_AUTHDOMAIN,
projectId: process.env.REACT_APP_PROJECTID,
storageBucket: process.env.REACT_APP_DEMOSTORAGEBUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGINGSENDERID,
appId: process.env.REACT_APP_APPID,
// measurementId: process.env.REACT_APP_MEASUREMENTID,
})
: initializeApp({
apiKey: process.env.REACT_APP_APIKEY,
authDomain: process.env.REACT_APP_AUTHDOMAIN,
projectId: process.env.REACT_APP_PROJECTID,
storageBucket: process.env.REACT_APP_STORAGEBUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGINGSENDERID,
appId: process.env.REACT_APP_APPID,
measurementId: process.env.REACT_APP_MEASUREMENTID,
});
export const auth = getAuth(app);
export const db = getFirestore(app);
export const storage = getStorage(app);
export const functions = getFunctions(app);
export const analytics = () => {
if (hostname === "localhost") {
return;
} else {
return getAnalytics(app);
}
};
if (hostname === "localhost") {
connectAuthEmulator(auth, "http://localhost:9099");
connectFirestoreEmulator(db, "localhost", 8080);
connectStorageEmulator(storage, "localhost", 9199);
connectFunctionsEmulator(functions, "localhost", 5001);
}
There are two other questions that came across this same issue and they both solved it by deleting/removing their "yarn-lock
" file, i'm using npm and i don't know what the consequences of deleting package-lock.json
.
firebase service storage is not available - React Js https://github.com/firebase/firebase-js-sdk/issues/6894
I looked up an answer to redo package-lock.json
and it told me to run npm install
. I ran it and nothing changed.
Deleting `package-lock.json` to Resolve Conflicts quickly
Any insights would be greatly appreciated.