Arun Purewal
Arun Purewal

Reputation: 457

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

App.Module.ts

import { AngularFireDatabase } from 'angularfire2/database';

imports: [    
    AngularFireDatabase
]

For some reason it keep's asking for me to add a @NgModule annotation when I don't need one. I am fairly new to Firebase.

I have tried adding this to my tsconfig.json file to see if it can pick up the angularfire2 modules but still no luck:

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

Upvotes: 1

Views: 6499

Answers (3)

Himanshu Joshi
Himanshu Joshi

Reputation: 126

In my case when I do "import {AngularFireDatabaseModule} from 'firebase2/database'" in app module class and "import {AngularFireDatabase} from 'firebase2/database'in app.component.ts problem get resolved. Don't use both in the same class -> app module and any .ts file in which you are doing firebase database work.

Upvotes: 1

Arun Purewal
Arun Purewal

Reputation: 457

I have managed to get rid of the error by using the following in my 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>

Upvotes: 0

R. Richards
R. Richards

Reputation: 25151

This is what you need in the app.module.ts in order to use that module.

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 about the product and configuration.

Another detailed resource.

Upvotes: 6

Related Questions