Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularFire2 - Cannot find module @firebase/database

I've installed and used AngularFire2 a lot of times for projects, but since the release of v5, I can't set it up correctly.

These are the steps I follow to reach the issue.

$ ionic start angularfire2test tabs
$ npm install angularfire2 firebase --save

package.json

"angularfire2": "^5.0.0-rc.3",
"firebase": "^4.5.2",

Add Firebase credentials to app.module.ts + import default module and database module. This is the most important part

import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
...
@NgModule({
  declarations: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    AngularFireModule.initializeApp(firebaseCredentials),
    AngularFireDatabaseModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
   ....

When I execute $ ionic serve, I get the error message "Cannot find module "@firebase/database" at webpackMissingModule (http://localhost:8100/build/vendor.js:119190:82)

When checking the node_modules folder, @firebase doesn't have a database subfolder, but the firebase-folder does have a database-folder.

Did I do something wrong or is it a general issue with AngularFire2?

like image 815
Matt Avatar asked Oct 19 '17 12:10

Matt


1 Answers

Install latest angularfire2 and [email protected]

npm install [email protected]
npm install angularfire2@latest

It is no longer necessary "--save", it remains implicit

like image 123
brianbha Avatar answered Oct 30 '22 02:10

brianbha