错误:找不到模块"angularfire2/database-deprecated"应用程序模块离子3,Angularfire2



我正在尝试连接到Firebase中的数据库。这是应用程序.模块.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { AngularFireDatabase, AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireModule } from 'angularfire2';
import { environment } from '../environments/environment';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(environment.firebase),
AngularFireDatabaseModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
AngularFireDatabase,
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}

错误在此行中

import { AngularFireDatabase, AngularFireDatabaseModule } from 'angularfire2/database';

我也试过这个 从'angularfire2/database-deprecated'导入{ AngularFireDatabase, AngularFireDatabaseModule };

但是错误只是改变了。

运行时错误找不到模块"angularfire2/database"堆栈错误: 找不到模块"角度火力2/数据库" 在对象.217 (http://localhost:8100/build/main.js:78:7( 在webpack_require(http://localhost:8100/build/vendor.js:55:30( 在对象.194 (http://localhost:8100/build/main.js:60:70( 在webpack_require(http://localhost:8100/build/vendor.js:55:30( at webpackJsonpCallback (http://localhost:8100/build/vendor.js:26:23( 在 http://localhost:8100/build/main.js:1:1

只需阅读此文档

在终端中:npm install firebase --save

在您的 app.module.ts 中创建 firebase 配置对象:

// Set the configuration for your app
// TODO: Replace with your project's config object
var config = {
apiKey: "apiKey",
authDomain: "projectId.firebaseapp.com",
databaseURL: "https://databaseName.firebaseio.com",
storageBucket: "bucket.appspot.com"
};
firebase.initializeApp(config);
// Get a reference to the database service
var database = firebase.database();

在 .ts 页上调用后:

import * as firebase from 'firebase';
"angularfire2": "^5.0.0-rc.10"

有问题 我的解决方案是卸载angularfire2^5.0.0-rc.10install angularfire2^5.0.0-rc.9

npm uninstall angularfire2
npm install angularfire2@5.0.0-rc.9

我确认这有效,通过@jsariasgeek解决

问题讨论

最新更新