模块 'AppModule' 导入了意外值 'AngularFireDatabase'。请添加@NgModule 注解

Unexpected value 'AngularFireDatabase' imported by the module 'AppModule'. Please add a @NgModule annotation

App.Module.ts

import { AngularFireDatabase } from 'angularfire2/database';

imports: [    
    AngularFireDatabase
]

出于某种原因,它一直要求我在不需要时添加 @NgModule 注释。我是 Firebase 的新手。

我已经尝试将它添加到我的 tsconfig.json 文件中,看看它是否可以获取 angularfire2 模块,但仍然没有成功:

"paths": {
  "@angular/*": [
    "../node_modules/@angular/*"
  ],

这是您在 app.module.ts 中使用该模块所需要的。

import { AngularFireDatabaseModule } from 'angularfire2/database';

// you may need this at some point if you do not have it already
import { AngularFireModule } from 'angularfire2'; 

...
imports: [
    AngularFireModule.initializeApp(<config>),
    AngularFireDatabaseModule 
]
...

Information关于产品和配置。

再详细resource.

我已经通过在我的 index.html 中使用以下内容设法摆脱了错误:

    <script src="/__/firebase/4.6.2/firebase-app.js"></script>
    <script src="/__/firebase/4.6.2/firebase-auth.js"></script>
    <script src="/__/firebase/4.6.2/firebase-database.js"></script>
    <script src="/__/firebase/4.6.2/firebase-messaging.js"></script>

以我为例 "import {AngularFireDatabaseModule} from 'firebase2/database'" 在应用程序模块 class 和“从 firebase2/database”中导入 {AngularFireDatabase} 在 app.component.ts 问题得到解决。 不要在同一个 class -> 应用程序模块和您正在执行 firebase 数据库工作的任何 .ts 文件中同时使用两者。