I'm trying to build a web app using firebase authentication, and I keep getting this error message. I'm using the Nextjs framework and everything should be working. I tried creating a new web app in firebase but that didn't work.
Below is the current code I have in firebase.js.
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
...
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
import { getAuth } from 'firebase/auth';
export const auth = getAuth(app);
Below is the error message I got.
FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists with different options or config (app/duplicate-app).
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
components\Firebase.js (17:26) @ eval
15 |
16 | // Initialize Firebase
> 17 | const app = initializeApp(firebaseConfig);
| ^
18 |
19 | import { getAuth } from 'firebase/auth';
20 |
This is what pops up in the console.
Uncaught at initializeApp (file:///C:/Users/Adam/Desktop/Chattr/chattr-app/node_modules/@firebase/app/dist/esm/index.esm2017.js:426:33)
at eval (webpack-internal:///./components/Firebase.js:25:72)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Here is the Package.json contents:
{
"name": "chattr-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"firebase": "^9.6.10",
"next": "12.1.0",
"react": "17.0.2",
"react-device-detect": "^2.1.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"eslint": "8.11.0",
"eslint-config-next": "12.1.0"
}
}
What should I do in this situation? Any help would be great.