首页 > 解决方案 > 角度 6 上的 firebase 错误

问题描述

我正在尝试将 firebase 添加到 angular 6 项目中。

npm install firebase angularfire2 --save

该项目基于 ngx-admin,并进行了一些修改。我是一个接触角度和打字稿的菜鸟。

运行上述命令后,尝试 ng serve给了我

node_modules/angularfire2/auth/auth.d.ts(4,10) 中的错误:错误 TS2305:模块 '"/Users/arash/Src/dance-admin/node_modules/firebase/app/index"' 没有导出的成员 '用户'。node_modules/angularfire2/auth/auth.d.ts(4,16):错误 TS2305:模块 '"/Users/arash/Src/dance-admin/node_modules/firebase/app/index"' 没有导出的成员 'auth' . node_modules/angularfire2/firebase.app.module.d.ts(2,10): error TS2305: Module '"/Users/arash/Src/dance-admin/node_modules/firebase/app/index"' 没有导出成员'应用程序'。node_modules/angularfire2/firebase.app.module.d.ts(2,15): error TS2305: Module '"/Users/arash/Src/dance-admin/node_modules/firebase/app/index"' 没有导出成员'身份验证'。节点模块/angularfire2/firebase。app.module.d.ts(2,21):错误 TS2305:模块“/Users/arash/Src/dance-admin/node_modules/firebase/app/index”没有导出成员“数据库”。node_modules/angularfire2/firebase.app.module.d.ts(2,31): error TS2305: Module '"/Users/arash/Src/dance-admin/node_modules/firebase/app/index"' 没有导出成员'火库”。node_modules/angularfire2/firebase.app.module.d.ts(2,42): error TS2305: Module '"/Users/arash/Src/dance-admin/node_modules/firebase/app/index"' 没有导出成员'功能'。node_modules/angularfire2/firebase.app.module.d.ts(2,53): error TS2305: Module '"/Users/arash/Src/dance-admin/node_modules/firebase/app/index"' 没有导出成员'消息传递”。node_modules/angularfire2/firebase.app。

```

我在这里很困惑,因为错误来自 angularfire2 内部,而不是我的项目。更令人费解的是,如果我对一个全新的 ng 应用程序做同样的事情,它就可以正常工作。

所以我想真正的问题是,这些错误信息是什么意思?由于 angularfire2 中的导入显然是正确的 - 至少在某些设置中是这样。

标签: angulartypescriptfirebase

解决方案


似乎最后一次更新打破了一些东西。此处列出了一项重大更改。在发布解决方案之前,您可以使用旧版本的 angularfire2。候选版本 9 似乎工作正常。只需编辑您的 package.json 并替换该行

"angularfire2": "^5.0.0-rc.10" // Gets the newest version

"angularfire2": "5.0.0-rc.9" // Gets a specific version

推荐阅读