0

I am trying to use firebase storage with React JS. but there is a error like this. service storage is not available

here is my firebase config file.

import { initializeApp } from "firebase/app";
import { Auth, getAuth } from "firebase/auth";
import { Firestore, getFirestore } from "firebase/firestore";
import { getStorage } from "firebase/storage";

// web app's Firebase configuration
const firebaseConfig = {
  apiKey: import.meta.env.VITE_API_KEY,
  authDomain: import.meta.env.VITE_AUTH_DOMAIN,
  projectId: import.meta.env.VITE_PROJECT_ID,
  storageBucket: import.meta.env.VITE_STORAGE_BUCKET,
  messagingSenderId: import.meta.env.VITE_MESSAGING_SENDER_ID,
  appId: import.meta.env.VITE_APP_ID,
};

// Initialize Firebase
export const firebase = initializeApp(firebaseConfig);

// exports
export const auth: Auth = getAuth(firebase);
export const db: Firestore = getFirestore(firebase);
export const storage = getStorage(firebase);

I have checked all the configs & everything is ok. Also I reinstalled the firebase package but nothing works out.

2 Answers2

1

I recently went through the same issue but deleting the .lock and node_modules did not do it for me.

As suggested [in this post][1], this happened as I had multiple versions of @firebase/app in my app. Running npm ls @firebase/app confirmed this. In my case that was @stripe/firestore-stripe-payments + the "actual" firebase package.

It is important to state that these dependencies had been working together without any issue for months before.

I removed one of the two dependency from the package.json, deleted the lock and node_modules, npm iied, re started the emulators and my app was back on its feet. I then re-installed the dependency I had removed and everything worked... fine. Quite unsettling to say the least. Hope this can help.

Stf_F
  • 846
  • 9
  • 23
  • For hours, I've been trying to resolve a similar issue in Angular. (app/no-app) `@stripe/firestore-stripe-payments` is the culprit. It appears to be unmaintained these days. I think I'll remove the dependency entirely. – Michael Sacket Aug 07 '23 at 16:09
0

problem solved!

maybe there is some firebase version issue in yarn.lock file. So I just deleted the yarn.lock file and after that, I've run the yarn command again. now it's working pretty fine