离子3

时间:2018-04-29 18:25:57

标签: angular firebase ionic-framework firebase-authentication

我正在使用离子3和Firebase版本4.13.1上的Firebase身份验证开发我的项目。我安装了Angularfire2。我创建了一个注册表单,并在使用ionic-lab测试我的应用程序时成功将用户详细信息放入firebase数据库。然而,当我关闭并重新打开我的项目时出现问题,我收到以下错误:

ERROR in ... node_modules / angularfire2 / firebase.app.module.d.ts(10,22):Class'FirebaseApp'错误地实现了类'FirebaseApp'。你的意思是扩展'FirebaseApp'并继承其成员作为子类吗? “FirebaseApp”类型中缺少属性“automaticDataCollectionEnabled”。

我通过将此行automaticDataCollectionEnabled: boolean;添加到此类 export declare class FirebaseApp implements _FirebaseApp { }

中解决了上述错误

现在我无法运行我的应用程序,因为它现在给我一个新错误:

运行时错误 区域已加载。

堆栈

Error: Zone already loaded.
    at http://localhost:8100/build/vendor.js:117594:15
    at http://localhost:8100/build/vendor.js:118206:3
    at FUNCTION (http://localhost:8100/build/vendor.js:117571:10)
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:117574:2)
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:120624:30)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.defineProperty.value (http://localhost:8100/build/vendor.js:69092:66)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.<anonymous> (http://localhost:8100/build/vendor.js:117089:72)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)

我以为我可能会加载模块两次,所以我试图删除: 来自index.html的<script src="build/vendor.js"></script>并得到一个新的运行时错误:没有定义webpack Jsonp。所以我把脚本放回去了。

我现在被困住了,非常感谢任何帮助。

3 个答案:

答案 0 :(得分:4)

我通过安装5.0.0-rc.4而不是5.0.0-rc.7来修复它,因为5.0.0-rc.4之后的所有内容似乎导致&#34;区域已加载&#34;

 npm install angularfire2@5.0.0-rc.4

答案 1 :(得分:3)

只做

npm install @firebase/app@latest --save

npm install firebase angularfire2 --save

所以一切都是最新的。所以你现在可能会再次出现这个错误:

  

node_modules / angularfire2 / firebase.app.module.d.ts(10,22):类'FirebaseApp'错误地实现了类'FirebaseApp'。你的意思是扩展'FirebaseApp'并继承其成员作为子类吗? “FirebaseApp”

类型中缺少属性“automaticDataCollectionEnabled”

要修复此问题,请将“automaticDataCollectionEnabled:boolean;”添加到node_modules\angularfire2\firebase.app.module.d.ts

export declare class FirebaseApp implements FBApp {
    name: string;
    automaticDataCollectionEnabled: boolean; // add this line
    options: {};
    auth: () => FirebaseAuth;
    database: () => FirebaseDatabase;
    messaging: () => FirebaseMessaging;
    storage: () => FirebaseStorage;
    delete: () => Promise;
    firestore: () => FirebaseFirestore;
}

所以现在应该修复它。如果没有,你必须尝试我的第二个解决方案:

npm i -S @firebase/app

然后进入你的package.json文件并将依赖项中这两行的版本号更新为:

"angularfire2": "5.0.0-rc.3",
"firebase": "4.6.0",

进行全新安装后:

npm install

然后再次发球,它应该再次运作:

ionic serve

答案 2 :(得分:0)

这是新firebase更新的问题,这是此错误的解决方案

**步骤:1 ** 使用此命令安装较低版本的firebase

  
    

npm install angularfire2@5.0.0-rc.4

  

**步骤:2 **

  
    

npm install

  

尝试。