firebase.intializeApp不是函数 [英] firebase.intializeApp is not a function

查看:113
本文介绍了firebase.intializeApp不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此我陷入了这个错误.我用电报bot API制作了电报bot,现在我试图建立一个firebae DB以保存组成员的分数-因此重新启动该bot后不会重置分数.有人可以告诉我问题是什么吗?我在这里阅读了许多其他类似的问题,但是这些答案都不能解决我的问题.

so im stuck at this error. Im making a telegram bot with the telegram bot api and now im trying to set up a firebae DB to save the score of a group member - so the score is not resetted after restarting the bot. can someone tell me what the problem is? i read a lot of other issues here with similiar problems, but none of these answers fixed my problem.

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);}
}
});

package.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.intializeApp中有错字.

You have a typo in firebase.intializeApp.

它应该是initializeApp.

It should be initializeApp.

var app = firebase.initializeApp({...});

这篇关于firebase.intializeApp不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆