Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularfire2 cant find module 'firebase/app'

app.component :

import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from 'angularfire2/firestore';
import { RoomComponent } from './component/room/room.component';
import { AngularFireAuth } from '@angular/fire/auth';
import { FirebaseService } from "./service/firebase.service";
import { AngularFireAuthModule } from 'angularfire2/auth';


imports: [
  BrowserModule,
  AngularFireModule.initializeApp(firebaseconfig),
  AngularFirestoreModule
],
providers: [
  FirebaseService,
  {
    provide: PERFECT_SCROLLBAR_CONFIG,
    useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
  },
  AngularFireAuth
],

package.json file :

{
"dependencies": {
"@angular/animations": "^5.2.11",
"@angular/cdk": "^5.2.4",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "^5.2.4",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"angularfire2": "^5.0.1",
"core-js": "^2.4.1",
"dateformat": "^3.0.3",
"firebase": "^5.5.1",
"rxjs": "^6.3.2",
"rxjs-compat": "^6.3.2",
  "zone.js": "^0.8.19"
  },
"devDependencies": {
"@angular/cli": "~1.7.4",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}

The imports that doesnt work located in a service:

import { AngularFirestore, AngularFirestoreCollection, 
   AngularFirestoreDocument } from 'angularfire2/firestore';
import { AngularFireAuth } from '@angular/fire/auth';
import { auth } from 'firebase/app'
import { Observable } from 'rxjs';

I only included the dependencies that may have something to do with the error but if i missed something please tell me.

I've already tried multiple versions. This does work but it has an error. The problem lies within the import { auth } which allows me to login to firebase. I dont know what the problem is. Sometimes it compiles, sometimes it doesn't. This is the only version combination I used so far that compile sometimes even with error. Other versions just breaks other imports.

The project only compiles if i remove the auth import momentarily and then put it back in then save it.

like image 729
Daniel Sanchez Avatar asked Sep 26 '18 17:09

Daniel Sanchez


2 Answers

npm install firebase

Solved my issue

like image 168
Prakash Poudel Avatar answered Nov 15 '22 09:11

Prakash Poudel


Install firebase using this command npm i @angular/fire

like image 25
Mohammed Osman Avatar answered Nov 15 '22 08:11

Mohammed Osman