不能让英雄服务器与Firebase数据库一起工作? Heroku崩溃?

好吧,我真的只是在这里错过了一个基本的理解。 我想要做的是:

  1. 使用firebase的托pipe和数据库 – 现在这个工程,因为我最初设置应用程序作为一个Firebase应用程序

  2. 只使用Heroku的服务器 – 我的理由是谷歌云function是有限的,不会让我做一个免费的计划等外部API调用

我有点新的这个设置,但到目前为止,我已经遵循https://firebase.google.com/docs/admin/setup和Heroku的设置说明。 我的项目 – 公众是我的公共HTML /文件:

在这里输入图像说明

我运行npm安装,并希望有英雄运行server.js作为我的服务器代码。 本地和正式运行,我一直在使用

firebase serve firebase deploy 

这两个工作没有错误,但没有服务器代码运行。 尝试heroku open or heroku local ,它崩溃与错误:

firebase实验:function:shell 2017-12-02T18:19:41.474319 + 00:00 app [web.1]:npm ERR! file sh 2017-12-02T18:19:41.471559 + 00:00 app [web.1]:sh:1:firebase:not found

这里是server.js,只是尝试一个简单的testing:

 const express = require('express'); const app = express(); const functions = require('firebase-functions'); const admin = require('firebase-admin'); // admin.initializeApp(functions.config().firebase); app.use('/', express.static(__dirname + '/public')); var serviceAccount = require("diverge-41a46-firebase-adminsdk-4yn47-29b6aaab49.json"); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: "https://diverge-41a46.firebaseio.com/" }); 'use strict'; console.log('HELLO WORLD'); const getIP = require('external-ip')(); var iplocation = require('iplocation'); // exports.helloWorld = functions.https.onRequest((request, response) => { // response.send("Hello from Firebase!"); // }); // exports.enterLocation = functions.database.ref('/Users/{name}') //brackets is client param // .onWrite(event => { // //console.log('SKYLAR HERE:', event.params.name); // returnLocation(); // //----------------------------------------- // // return event.data.adminRef.set({ location: 'test loc'}); // }); app.get('/', function (req, res) { res.send('Hello World'); }) app.listen(5000, function () { //process.env.PORT || 5000 console.log('Listening on port ', 5000); }) 

和package.json(最上面的部分是从尝试云function中遗留下来的):

 { "name": "functions", "description": "Cloud Functions for Firebase", "scripts": { "serve": "firebase serve --only functions", "shell": "firebase experimental:functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log" }, "dependencies": { "express": "^4.16.2", "external-ip": "^1.3.1", "firebase-admin": "^5.5.0", "firebase-functions": "^0.7.3", "iplocation": "^5.0.0", "request": "^2.83.0" }, "private": true } 

我在教程中指出.initializeApp位时,我从Firebase下载了我的私钥,所以应该全部连接起来。

我在这里做错了什么?