angular - 如何在不使用 angularfire2 的情况下在 angular2 中使用 firebase3
我一直在使用 Angular2 快速入门代码来构建一个基本的待办事项应用。
我想添加一个登录页面并连接到 Firebase 来存储和检索待办事项,但在使用 Firebase3 实现时遇到了问题。
我可以通过在启动脚本(如下所示)中移除对 tsc 的调用来让它工作,但这似乎只是一个短期解决办法。
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" "
当我运行 npm start 时收到的错误提示说在我组件的 .tsc 文件中使用 firebase 的任何地方都找不到名称 firebase。我还注意到我还没有找到 Firebase 3 的全局类型下载,所以只有 Firebase 2 的类型定义。
Firebase 2 和 3 的布局差异(Firebase 3 完全在 index.html 中,而 Firebase 2 似乎在各处声明)会导致这个问题吗???
请注意,我的 Firebase 经验非常有限,所以我可能会误解 fb2 和 fb3 之间的区别。
下面是我在 npm start 上当前得到的错误
> [email start /Users/ahiggins/Documents/angular_2/tutorials/todo
> tsc && concurrently "npm run tsc:w" "npm run lite"
app/login/login.component.ts(25,9): error TS2304: Cannot find name 'firebase'.
app/login/login.component.ts(47,9): error TS2304: Cannot find name 'firebase'.
app/login/login.component.ts(56,13): error TS2304: Cannot find name 'firebase'.
app/login/login.component.ts(59,56): error TS2304: Cannot find name 'firebase'.
app/app.component.ts(16,9): error TS2304: Cannot find name 'firebase'.
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.4.0/bin/node" "/Users/ahiggins/.npm-packages/bin/npm" "start"
npm ERR! node v6.4.0
npm ERR! npm v3.10.6
npm ERR! code ELIFECYCLE
npm ERR! [email start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc && concurrently "npm run tsc:w" "npm run lite"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.