I have been developing a Next.js application that retrieves data from a Firebase collection. During the process of connecting to the Firebase database, I have come across the following error:
Failed to compile. Module not found
This error seems to be originating from the config.js file containing Firebase credentials located at: root > src > firebase > config.js
Upon running npm firebase -v
, it shows the installed version as 8.19.2
However, the package.json indicates that it should be ^9.8.0
I have attempted to update Firebase but encountered issues with the update.
The structure of the config file is as follows:
import firebase from 'firebase';
import { initializeApp } from 'firebase-admin';
import { getFirestore } from 'firebase/firestore';
const firebaseConfig = {
apiKey: "xxxx",
authDomain: "xxxx",
projectId: "xxxx",
storageBucket: "xxxx",
messagingSenderId: "xxxx",
appId: "xxxx",
measurementId: "xxxx"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
export default db;
And this is how the package.json file looks like:
{
"name": "with-redux-toolkit",
"version": "1.0.0",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
...
},
"license": "MIT",
"devDependencies": {
...
}
}
If anyone has any insights or solutions regarding this issue, I would greatly appreciate your help.
Thank you in advance.