I'm working on a React project setup using node 16.17.0
, Create React App "react-scripts": "^5.0.0"
with "react": "^17.0.2"
Everything was working fine until this morning. When I try to npm run start
or npm run build
, it gives me the below error. The npm install
works fine showing no errors.
The errors that I am getting are:
ERROR in ./src/services/auth/firebase/firebase.js 3:0-45
Module not found: Error: Default condition should be last one
ERROR in ./src/services/auth/firebase/firebase.js 4:0-40
Module not found: Error: Default condition should be last one
ERROR in ./src/app/pages/payout/PayoutOpen.js 5:0-39
Module not found: Error: Default condition should be last one
ERROR in ./node_modules/@react-query-firebase/auth/dist/bundle.es.js 3:0-78
Module not found: Error: Default condition should be last one
ERROR in ./node_modules/@react-query-firebase/auth/dist/bundle.es.js 4:0-720
Module not found: Error: Default condition should be last one
This is how my firebase.js
file looks like:
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
const firebase = initializeApp({
apiKey: "********",
authDomain: "*******",
projectId: "*********",
storageBucket: "**********",
messagingSenderId: "***************",
appId: "****************",
measurementId: "*************"
});
export const auth = getAuth(firebase);
I tried to remove node_modules
folder, remove package-lock.json
file, clear npm cache but nothing works. I also tried to install using yarn but it shows the same error.
CodePudding user response:
Fresh issue as per 03 Feb 2023, happens due to firebase v9.17.0
.
Fix:
- npm un firebase
- npm i [email protected]
Or:
- modify package.json, use
"firebase": "9.16.0"
instead of"firebase": "^9.16.0"
. - run
npm i
oryarn
.
Related github issue: https://github.com/firebase/firebase-js-sdk/issues/7005