I’m a newbie and was developing my first project with React Native and Firebase. I already did npm install firebase have a FirebaseConfig.js file that looks like this:
// 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
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyBkkFcJIQipjxJzWxZy9Rl0N7Yfavz2JRI",
authDomain: "locked-in-2bc92.firebaseapp.com",
projectId: "locked-in-2bc92",
storageBucket: "locked-in-2bc92.appspot.com",
messagingSenderId: "421293481166",
appId: "1:421293481166:web:7f3e386eb0828d1183849f",
measurementId: "G-EPQ6G0KSG2"
};
// Initialize Firebase
export const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
I’m getting the following:
Error: Unable to resolve module firebase/app from C:UsersshahvLocked-InconfigsFirebaseConfig.js: firebase/app could not be found within the project or in these directories:
node_modules
1 | // Import the functions you need from the SDKs you need
2 | import { initializeApp } from “firebase/app”;
However, I’ve checked at firebase is in node.modules. My package.json looks like this:
{
"name": "locked-in",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"reset-project": "node ./scripts/reset-project.js",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"test": "jest --watchAll",
"lint": "expo lint"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "^14.0.2",
"@react-navigation/native": "^6.0.2",
"expo": "~51.0.26",
"expo-constants": "~16.0.2",
"expo-font": "~12.0.9",
"expo-linear-gradient": "~13.0.2",
"expo-linking": "~6.3.1",
"expo-router": "~3.5.21",
"expo-splash-screen": "~0.27.5",
"expo-status-bar": "~1.12.1",
"expo-system-ui": "~3.0.7",
"expo-web-browser": "~13.0.3",
"firebase": "^10.13.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.5",
"react-native-gesture-handler": "~2.16.1",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-web": "~0.19.10"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/jest": "^29.5.12",
"@types/react": "~18.2.45",
"@types/react-test-renderer": "^18.0.7",
"jest": "^29.2.1",
"jest-expo": "~51.0.3",
"react-test-renderer": "18.2.0",
"typescript": "~5.3.3"
},
"private": true
}
I did exactly what firebase documentation told me to do. But I can’t even get past this first step. I’m using import { initializeApp } from "firebase/app";
but i dont known why its not recognizing it.
Shahvir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.