TypeError:Firebase 不是函数

     2023-03-07     165

关键词:

【中文标题】TypeError:Firebase 不是函数【英文标题】:TypeError: Firebase is not a function 【发布时间】:2016-09-19 01:31:24 【问题描述】:

我正在尝试遵循 firebase 节点教程: https://www.firebase.com/docs/web/quickstart.html

我的 node.js 应用程序因“”错误而崩溃。我的 index.js 文件:

var Firebase = require("firebase");
var firebaseRef = new Firebase("https://word-word-number.firebaseio.com/");

第二行是崩溃发生的地方。

在我的 package.json 我有:

"firebase": "^3.0.2",

"node": "5.11.0"

【问题讨论】:

【参考方案1】:

事实证明,firebase.com 教程已经过时,说明应该如何使用最新的 firebase 包。以下是来自https://www.npmjs.com/package/firebase的新说明

在您的代码中,您可以使用以下方式访问 Firebase:

var firebase = require('firebase');
firebase.intializeApp(
  apiKey: '<your-api-key>',
  authDomain: '<your-auth-domain>',
  databaseURL: '<your-database-url>',
  storageBucket: '<your-storage-bucket>'
);

或者,如果您在新的 Google Firebase 仪表板中通过权限设置Service Account,请使用此处新的官方文档中引用的方法:

https://firebase.google.com/docs/server/setup#add_the_sdk

【讨论】:

这就是您首先查看official documentation 的原因。它包含更新的文档和迁移指南 作为 Firebase 的新手,我没有意识到 firebase.com 文档不是官方文档。希望这篇文章对处于相同位置的其他人有用。 firebase.com 是官方网站,因为它是他们的网站,但在他们的首页上,他们会通知您他们有一个更新的网站,位于 firebase.google.com【参考方案2】:

更新了 nodeJs 用户的文档 https://firebase.google.com/support/guides/firebase-web#get_a_database_reference_numbered 这可能会修复所有这些错误。

【讨论】:

TypeError: firebase.auth(...).onAuthStateChanged 不是函数

】TypeError:firebase.auth(...).onAuthStateChanged不是函数【英文标题】:TypeError:firebase.auth(...).onAuthStateChangedisnotafunction【发布时间】:2018-08-1707:09:37【问题描述】:我正在尝试使用onAuthStateChanged触发器,但在使用“firebasedeploy”时我得到... 查看详情

FireBase + React:TypeError:user.getToken 不是函数

】FireBase+React:TypeError:user.getToken不是函数【英文标题】:FireBase+React:TypeError:user.getTokenisnotafunction【发布时间】:2020-10-1223:18:58【问题描述】:这里的代码signInWithEmailAndPassword可以完美运行,但是当我尝试获取令牌时,总是会抛... 查看详情

未捕获的 TypeError: (0 , _firebase.auth) 不是函数

】未捕获的TypeError:(0,_firebase.auth)不是函数【英文标题】:UncaughtTypeError:(0,_firebase.auth)isnotafunction【发布时间】:2018-07-1417:59:06【问题描述】:尝试在React应用中使用Firebase身份验证。我按照firbase文档中的说明进行操作。使用npm安... 查看详情

TypeError: Buffer.alloc 在访问 firebase 工具时不是函数

】TypeError:Buffer.alloc在访问firebase工具时不是函数【英文标题】:TypeError:Buffer.allocisnotafunctionwhileaccessingfirebasetools【发布时间】:2018-01-2723:17:34【问题描述】:我正在尝试从我的终端访问firebase控制台,但由于这个错误,我也无法... 查看详情

TypeError: u.indexOf 不是 Reactjs 和 Firebase 的函数

】TypeError:u.indexOf不是Reactjs和Firebase的函数【英文标题】:TypeError:u.indexOfisnotafunctionforReactjsandFirebase【发布时间】:2021-06-1109:27:06【问题描述】:我在学习本教程时遇到以下错误https://www.youtube.com/watch?v=QiTq5WrWoJw&t=8176s我在将个... 查看详情

TypeError: dart.global.firebase.storage 不是 Flutter web 上的函数

】TypeError:dart.global.firebase.storage不是Flutterweb上的函数【英文标题】:TypeError:dart.global.firebase.storageisnotafunctiononFlutterweb【发布时间】:2021-04-2511:33:57【问题描述】:我在使用Flutterweb时遇到了这个问题。在我的index.html中看起来像这... 查看详情

flutter web TypeError: dart.global.firebase.storage 不是函数

】flutterwebTypeError:dart.global.firebase.storage不是函数【英文标题】:flutterwebTypeError:dart.global.firebase.storageisnotafunction【发布时间】:2021-04-2917:53:09【问题描述】:我正在用Flutter构建一个网络应用程序,试图将照片添加到Firebase存储中... 查看详情

TypeError:rtdb.initStandalone 不是函数

】TypeError:rtdb.initStandalone不是函数【英文标题】:TypeError:rtdb.initStandaloneisnotafunction【发布时间】:2018-06-2406:33:22【问题描述】:我对Node和Firebase都很陌生,但似乎无法在线找到此错误。当我尝试通过FirebaseAdmin加载Firebase数据库... 查看详情

在 Jest 中模拟 Firebase 管理员时出错:“TypeError:admin.firestore 不是函数”

】在Jest中模拟Firebase管理员时出错:“TypeError:admin.firestore不是函数”【英文标题】:ErrorMockingFirebaseAdmininJest:"TypeError:admin.firestoreisnotafunction"【发布时间】:2020-08-2411:07:21【问题描述】:我有一个函数来处理通过AdminSDK... 查看详情

TypeError: _app.default.auth 不是一个函数 - React Native Web - Firebase

】TypeError:_app.default.auth不是一个函数-ReactNativeWeb-Firebase【英文标题】:TypeError:_app.default.authisnotafunction-ReactNativeWeb-Firebase【发布时间】:2022-01-1917:51:54【问题描述】:我目前正在ReactNativeWeb上开发一个项目,这是我在组件中的登... 查看详情

将 Firebase 集成到 Vue.js 2 时出现“未捕获的 TypeError:firebaseApp.firestore 不是函数”

】将Firebase集成到Vue.js2时出现“未捕获的TypeError:firebaseApp.firestore不是函数”【英文标题】:\'UncaughtTypeError:firebaseApp.firestoreisnotafunction\'whenintegratingFirebasetoVue.js2【发布时间】:2021-11-1307:48:28【问题描述】:检查时出现此错误>... 查看详情

TypeError: urls.map 不是 React 中的函数

】TypeError:urls.map不是React中的函数【英文标题】:TypeError:urls.mapisnotafunctioninReact【发布时间】:2021-06-1712:06:23【问题描述】:我必须在反应中显示图像时遇到问题。从firebase存储中获取的所有图像url列表。传递所有url显示图像显... 查看详情

TypeError: Object(…) 不是函数

】TypeError:Object(…)不是函数【英文标题】:TypeError:Object(…)isnotafunction【发布时间】:2019-08-1201:34:30【问题描述】:我正在尝试使用Firebase和Redux执行身份验证。当我尝试登录时,我收到一个错误:“UncaughtTypeError:Object(...)isnotafunc... 查看详情

TypeError:messaging.getToken 不是函数

】TypeError:messaging.getToken不是函数【英文标题】:TypeError:messaging.getTokenisnotafunction【发布时间】:2021-09-1508:59:45【问题描述】:所以我正在开发一个Firebase云消息传递网络应用程序并收到错误:Error:TypeError:messaging.getTokenisnotafuncti... 查看详情

firebase.database 不是函数

...我被困在最后一条语句firebase.database().ref();上。错误信息TypeError:firebase. 查看详情

FireStore - TypeError:k.setTimeout 不是函数

】FireStore-TypeError:k.setTimeout不是函数【英文标题】:FireStore-TypeError:k.setTimeoutisnotafunction【发布时间】:2018-03-2509:29:04【问题描述】:我在ReactNative应用程序中使用Firebase并使用facebook令牌进行身份验证。它适用于实时数据库。但... 查看详情

类型错误:firebase.auth() 不是函数

】类型错误:firebase.auth()不是函数【英文标题】:TypeError:firebase.auth()isnotafunction【发布时间】:2019-10-2302:16:47【问题描述】:我正在设置一个新的firebase项目。在项目中,我尝试使用firebase.auth()使用用户电子邮件和密码创建一个... 查看详情

TypeError:未定义不是一个对象(评估'_app.firebase.apps')

】TypeError:未定义不是一个对象(评估\\\'_app.firebase.apps\\\')【英文标题】:TypeError:undefinedisnotanobject(evaluating\'_app.firebase.apps\')TypeError:未定义不是一个对象(评估\'_app.firebase.apps\')【发布时间】:2022-01-1711:35:33【问题描述】:... 查看详情