인프런 커뮤니티 질문&답변
이런 오류메세지가 뜹니다
해결된 질문
작성
·
884
0
또 질문드리게 되어 송구합니다
안드로이드에서 실행하니 아래와 같은 오류메세지가 보이네요 ...
While trying to resolve module `firebase` from file `D:\study\ReactNative\app_expo\src\firebase.js`, the package `D:\study\ReactNative\app_expo\node_modules\firebase\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`D:\study\ReactNative\app_expo\node_modules\firebase\index`. Indeed, none of these files exist: * D:\study\ReactNative\app_expo\node_modules\firebase\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json) * D:\study\ReactNative\app_expo\node_modules\firebase\index\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
전체 코드는 깃헙에 올려두었습니다
https://github.com/dongguntechnology/rn-chat
답변 2
0
shafeel2
질문자
감사합니다
아래와 같이 수정하니 에러가 사라졌네요
firebase.json
{
"apiKey": "AIzaSyAZa98BWH1jGXMNvtTzD-wGf4Hbjbgkqh0",
"authDomain": "rn-chat-1f941.firebaseapp.com",
"projectId": "rn-chat-1f941",
"databaseURL": "https://rn-chat-1f941.firebaseio.com",
"storageBucket": "rn-chat-1f941.appspot.com",
"messagingSenderId": "293554822855",
"appId": "1:293554822855:web:785a89c24b7ac7bb7768e2",
"measurementId": "G-KRKJKMVF9H"
}
firebase.js
import {initializeApp} from 'firebase/app';
import {getAuth} from 'firebase/auth';
import config from '../firebase.json';
const app = initializeApp(config);
const Auth = getAuth(app);
export const signin = async ({email, password}) => {
const {user} = await Auth.signInWithEmailAndPassword(email, password);
return user;
};
0
김범준
지식공유자
안녕하세요 shafeel2 님,
firebase 라이브러리 버전이 달라서 사용법에 차이가 조금 있습니다.
다음과 같이 코드를 변경해주세요.
/src/firebase.js
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import config from '../firebase.json';
const app = initializeApp(config);
const Auth = getAuth(app);
export const siginin = async ~;
이후 firebase를 사용하는 코드들도 약간씩 사용방법에 차이가 있을 수 있습니다.
자세한 사용 방법은 firebase 공식문서를 참고해주세요.
링크 : https://firebase.google.com/docs/reference/js?authuser=0
혹은 expo 공식 문서의 firebase 부분을 참고하셔도 도움이 됩니다.
링크 : https://docs.expo.dev/guides/using-firebase/
추가적으로 firebase.json 파일이 json 형식이 아닙니다.
json 형식에 맞게 다음과 같이 코드를 수정하시기 바랍니다.
{
"apiKey": "~",
~
}
즐거운 하루 되세요
감사합니다.





