Yousaf Azabi
Yousaf Azabi

Reputation: 101

Import firebase/app used to work now I got error (firestore is not a function)?

I am using React and Redux. I imported firebase using import shown below:

import * as firebase from 'firebase/app'
import 'firebase/firestore'

Everything was working then I committed changes and pushed them to GitHub. My colleague pulled the code and told me to test it and it was not working. I tried to run the code but not working. I changed the import to:

import * as firebase from 'firebase/firebase'
import 'firebase/firestore'

the code is working now. If anyone has an idea what is the reason for this error can you please help me to understand this issue.

Upvotes: 4

Views: 6877

Answers (1)

Yousaf Azabi
Yousaf Azabi

Reputation: 101

I deleted package-lock.json file

Then run npm install

I received this warning

npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @firebase/[email protected] requires a peer of @firebase/[email protected] but none is installed. You must install peer dependencies yourself.

I re-installed firebase

npm install --save firebase

and problem solved. No warnings or errors and it is back to work as before.

Upvotes: 2

Related Questions