web-dev-qa-db-fra.com

Est-il possible d'utiliser angularfire2 avec Angular 6?

J'essaie d'ajouter un support firebase à mon application Angular 6 

npm install angularfire2 firebase

Je reçois beaucoup d’avertissement en disant que je dois utiliser Angular 5. Par exemple

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

Est-il possible d'utiliser angularfire2 avec Angular 6 aujourd'hui?

Je reçois cette erreur lors de la compilation:

ERROR in node_modules/angularfire2/angularfire2.d.ts(3,10): error TS2305: Module '"/home/rrr/Projects/ng6test/node_modules/rxjs/Subscription"' has no exported member 'Subscription'.
node_modules/angularfire2/firebase.app.module.d.ts(10,22): error TS2720: Class 'FirebaseApp' incorrectly implements class 'FirebaseApp'. Did you mean to extend 'FirebaseApp' and inherit its members as a subclass?
  Property 'automaticDataCollectionEnabled' is missing in type 'FirebaseApp'.
node_modules/rxjs/Subscription.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subscription'.

J'ai essayé d'installer rxjs-compat, mais je reçois un autre avertissement après cela.

ERROR in node_modules/angularfire2/firebase.app.module.d.ts(10,22): error TS2720: Class 'FirebaseApp' incorrectly implements class 'FirebaseApp'. Did you mean to extend 'FirebaseApp' and inherit its members as a subclass?
  Property 'automaticDataCollectionEnabled' is missing in type 'FirebaseApp'.
9
krk999

J'ai essayé et je ne peux pas utiliser Angular 6 avec aucune version d'AngularFire2 (dernière version: 5.0.0-rc.7.2-next). Je suppose que nous devons attendre la prochaine version majeure de AngularFire2.

Mettre à jour:
Un temporaire solution consiste à installer rxjs-compat.
npm install --save rxjs-compat

4
6324

essayer:

npm install firebase angularfire2@next --save

Corrigé dans la version pré-publiée: 

angularfire2@next
1
WebDevDaniel

package.json

"dependencies": 
{
"@angular/animations": "^6.0.3",
"@angular/cdk": "^6.1.0",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.0.3",
"@angular/http": "^6.0.3",
"@angular/material": "^6.1.0",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@firebase/app": "^0.3.3",
"angularfire2": "^5.0.0-rc.10",
"core-js": "^2.5.6",
"firebase": "^5.0.3",
"hammerjs": "^2.0.8",
"rxjs": "^6.2.0",
"rxjs-compat": "^6.2.0",
"zone.js": "^0.8.26"
}

app.module.ts

import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { environment } from '../environments/environment';

@ngModule 

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        routing,
        FormsModule,
        HttpClientModule,
        AngularFireModule.initializeApp(environment.firebase),
        AngularFireDatabaseModule,
        AngularFireAuthModule

    ]
})

environnement 

firebase: {
    apiKey: "apikey",
    authDomain: "authDomain",
    databaseURL: "https://projectId.firebaseio.com",
    projectId: "projectId",
    storageBucket: "projectId.appspot.com",
    messagingSenderId: "messagingSenderId"
  }
0
Leonidas Gorgo