Firebase.initialize不是函数,我是否缺少软件包?

时间:2018-09-26 11:52:17

标签: node.js firebase npm google-cloud-functions actions-on-google

我正在尝试创建一个可以访问我的数据库的firebase函数。但是,当我运行 firebase deploy --only函数时,出现以下错误:

TypeError: firebase.initializeApp is not a function
    at Object.<anonymous> (C:\Users\xxx\Documents\TriviaGame\functions\index.js:34:10)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at C:\Users\xxx\AppData\Roaming\npm\node_modules\firebase-tools\lib\triggerParser.js:21:11
    at Object.<anonymous> (C:\Users\xxx\AppData\Roaming\npm\node_modules\firebase-tools\lib\triggerParser.js:75:3)

这是我的代码:

'use strict';


var firebase = require('firebase');
const {actionssdk} = require('actions-on-google');
const functions = require('firebase-functions');

const app = actionssdk({debug: true});


var config = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: ""
};
firebase.initializeApp(config);
var database=firebase.database();
var allMyStuff = database.ref('triviagame');

//do stuff with my database values

1 个答案:

答案 0 :(得分:1)

npm install firebase在我的函数目录中,更新了我的软件包,并允许我访问initializeApp()函数。