firebase.intializeApp 不是一个函数

2024-03-03

所以我陷入了这个错误。我使用 telegram bot api 制作了一个 telegram 机器人,现在尝试设置一个 firebae DB 来保存组成员的分数 - 因此重新启动机器人后分数不会重置。有人可以告诉我问题是什么吗?我在这里读到了很多其他有类似问题的问题,但这些答案都没有解决我的问题。

bot.js

var TelegramBot = require('node-telegram-bot-api');
var firebase = require('firebase');

var token = 'mytoken';
// Setup polling way
var bot = new TelegramBot(token, {polling: true});

var app = firebase.intializeApp({
  serviceAccount: "C:/Mayer/scorebot/telegramscorebot.json",
  databaseURL: "https://blazing-heat-2008.firebaseio.com/"
});


/* function Person(name, score) {
this.name = name;
this.score = score;
}

var member = new Array();
member[0] = new Person("name1", 0);
member[1] = new Person("name2", 0);
member[2] = new Person("name3", 0);
member[3] = new Person("name4", 0);
member[4] = new Person("name5", 0); */

bot.onText(/\/echo (.+)/, function (msg, match) {
  var fromId = msg.from.id;
  if (match[1] == 'test') {
  var resp = match[1];
  bot.sendMessage(fromId, resp); }
  else {
  bot.sendMessage(fromId, 'error!!');}
});

bot.onText(/\/vote (.+)/, function (msg, match) {
  var fromId = msg.from.id;

for (var i = 0; i <= 4; i++) {
    if(member[i].name == match[1]){
        member[i].score += 1;
        bot.sendMessage(fromId, member[i].name + ' hat einen Score von ' +         member[i].score);}
}
});

包.json

   {
   "name": "scorebot",
   "version": "1.0.0",
   "description": "",
   "main": "bot.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node bot.js"
   },
   "author": "me",
   "license": "ISC",
   "dependencies": {
     "bower": "1.7.9",
    "firebase": "3.0.2"
   }
 }

错误信息

 bot.js:8 var app = firebase.intializeApp({
                    ^

  TypeError: firebase.intializeApp is not a function
      at Object.<anonymous> (C:\Mayer\scorebot\bot.js:8:20)
      at Module._compile (module.js:413:34)
      at Object.Module._extensions..js (module.js:422:10)
      at Module.load (module.js:357:32)
      at Function.Module._load (module.js:314:12)
      at Function.Module.runMain (module.js:447:10)
      at startup (node.js:141:18)
      at node.js:933:3

您在 firebase.initializeApp 中有一个拼写错误。

应该是initializeApp。

var app = firebase.initializeApp({...});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

firebase.intializeApp 不是一个函数 的相关文章

  • web3.eth.sendSignedTransaction() 总是返回“返回错误:nonce 太低”

    I used 电子邮件受保护 cdn cgi l email protection在 Node js 中与私有区块链交互 我是按照官方文档写的代码 电子邮件受保护 cdn cgi l email protection var Web3 re
  • 如何在node.js中存根process.env?

    我想存根process env FOO with bar var sinon require sinon var stub sinon stub process env FOO bar 我很困惑 我阅读了文档 但仍然不明白 sinonjs
  • Firestore 查询 .toUpperCase() 不起作用

    我正在尝试创建一个网站 使用户能够搜索 Firebase Firestore 中的文档集合 该过程涉及将用户的输入保存为状态 useState 并利用 useEffect 挂钩来查询 Firebase 数据库 但是 我遇到了一个问题 即使用
  • Node js mongodb 删除错误“key $lte 不得以 '$' 开头”

    db collection session remove timestamp lte a function err docs console log err console log docs Version mongodb is 2 6 5
  • 纤维/未来实际上有什么作用?

    下面这行代码的作用是什么 Npm require fibers future 我在网上查找示例 发现了一些这样的示例 Future Npm require fibers future var accessToken new Future 什
  • 电报机器人预填充文本供用户编辑

    Telegram 机器人向我发送一条带有文本片段的消息 我想要编辑该文本片段 然后发送回机器人进行进一步处理 复制和粘贴需要时间 重新输入消息需要时间 理想情况下 我想按机器人消息上的内联按钮 编辑 并使消息文本出现在我的回复输入框中进行编
  • Node.js 升级在 Windows 中仍然显示旧版本

    我已使用 msi 安装程序下载并安装了新版本的 nodejs 4 1 2 之后我跑了node v 但它仍然显示旧版本 0 12 2 我尝试重新启动Windows 甚至卸载nodejs并重新安装它 但仍然显示相同的内容 为什么会发生这种情况
  • javascript 是否有等效的 __repr__ ?

    我最接近Python的东西repr这是 function User name password this name name this password password User prototype toString function r
  • angularfire 2:错误“未处理的承诺拒绝:TypeError:无法读取属性”

    我尝试了一个示例应用程序来连接到 Firebase 在我的 Main ts 中我这样写 import bootstrap from angular platform browser dynamic import enableProdMode
  • Node.js http get 请求错误事件未拾取 404 或 403

    我正在对图像发出 HTTP GET 请求 有时图像会以 404 或 403 的形式返回 令我惊讶的是 我必须明确检查这一点 而不是在错误事件中选择它 这是它的工作原理还是我在这里遗漏了一些东西 function processRequest
  • Node.js 重写 toString

    我试图覆盖我的对象的默认 toString 方法 这是代码和问题 function test this code 0 later on I will set these this name test prototype toString f
  • editMessageReplyMarkup 方法删除内联键盘

    我正在使用 node js 制作一个电报机器人node telegram bot api图书馆 我回答callback query并想更换我的内联键盘 下面的代码显示了我如何尝试使用此方法 但是当我在电报中点击键盘时 它就消失了 bot o
  • NestJS e2e 测试模拟会话装饰器

    我正在尝试使用 supertest 编写一个 e2e 测试 其中我的控制器实际上使用了 Session 装饰师 然而 我不想承担使用数据库连接等启动会话的全部负担 因此测试中的我的应用程序实际上并未初始化会话 相反 我想首先模拟掉装饰器提供
  • firebase 和 firebase-admin npm 模块有什么区别?

    我想使用 Firebase 身份验证 数据库和存储 构建 Node js Web 应用程序 但我对应该使用哪个模块感到困惑 firebase or firebase 管理员 或两者 管理 SDK 运行您的代码管理权限 https fireb
  • 从 Firebase 数据库填充微调器

    public class MainActivity extends AppCompatActivity DatabaseReference reference Spinner areaSpinner ArrayList
  • 如何使用Create React App安装React

    嗨 我对反应真的很陌生 我不知道如何实际安装它 也不知道我需要做什么才能在其中编写代码 我下载了node js并且安装了v12 18 3以及NPM 6 14 6 但是每次我尝试在许多网站上提到的create react app安装方法中输入
  • 如何在超级测试中模拟中间件?

    我想测试中间件是否在app js叫做 虽然我嘲笑该模块work js 它仍然运行原始代码 app js const work require work const express require require const app expr
  • Nodejs Express中间件函数返回值

    我正在使用 NodeJS 和 Express 我有以下路线 中间件功能是Mobile 如果我不使用 return next 在 isMobile 函数中 应用程序会卡住 因为 NodeJS 不会移至下一个函数 但我需要 isMobile 函
  • Node.js 和 Passport 对象没有 validPassword 方法

    我正在使用 Node js Express Passport 创建一个简单的身份验证 本地 到目前为止我所达到的效果是 当输入错误的用户名或密码时 用户将被重定向到错误页面 但是当用户输入正确的用户名和密码时 我收到此错误 node mod
  • 无法将 admob 与 firebase iOS/Android 项目链接

    我有两个帐户 A 和 B A 是在 Firebase 上托管 iOS Android unity 手机游戏的主帐户 B 用于将 admob 集成到 iOS Android 手机游戏中 我在尝试将 admob 分析链接到 Firebase 项

随机推荐