嗨,我是angular和firebase的新手,从今天早上开始,我一直在努力编写简单的代码,我搜索了这个问题,但没有找到任何适用于我的解决方案(有时我什至不理解它,我是一个真正的初学者)
我在控制台上遇到的错误如下:



这是我的代码:
app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AngularFireModule } from "angularfire2";
import { AngularFireDatabaseModule, AngularFireDatabase } from "angularfire2/database";
import { AppComponent } from './app.component';
import { environment } from '../environments/environment';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireDatabase
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts
import { Component } from '@angular/core';

import { Observable } from 'rxjs/Observable';
import { AngularFireDatabase } from "angularfire2/database";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

   }
}

软件包的依赖项.json
  "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/platform-server": "^5.1.2",
    "@angular/router": "^5.0.0",
    "@angular/service-worker": "^5.1.2",
    "angularfire2": "^5.0.0-rc.4",
    "core-js": "^2.4.1",
    "firebase": "4.8.0",
    "ng-push": "^0.2.1",
    "ng-pwa-tools": "0.0.15",
    "rxjs": "^5.5.2",
    "webpack": "^3.10.0",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.2",
    "@angular/compiler-cli": "^5.0.0",
    "@angular/language-service": "^5.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }

我已经尝试过多次重新安装一切,但似乎没有任何效果,希望大家可以帮助我

最佳答案

,我认为您需要更改导入,以用AngularFireDatabase替换AngularFireDatabaseModule:

  imports: [
    ...
    AngularFireDatabaseModule
  ],

,并从模块导入中删除AngularFireDatabase:
import { AngularFireDatabaseModule } from "angularfire2/database";

您正在导入AngularFireDatabase而不是模块。 AngularFireDatabase应该仅导入组件中。

07-27 21:56