Javascript Firebase云函数-将函数拆分为多个.JS文件时函数预部署错误

Javascript Firebase云函数-将函数拆分为多个.JS文件时函数预部署错误,javascript,firebase,google-cloud-functions,Javascript,Firebase,Google Cloud Functions,我了解云功能最近更新到v1.0 我正在尝试从Android Studio中编写多个函数。我计划拥有多个云功能,并希望确保我的数据结构是正确的。以下是我的当前设置: index.js const functions = require('firebase-functions'); const trackVote = require('./trackVote') const trendingCopy = require('./trendingCopy') const admin = require

我了解云功能最近更新到v1.0

我正在尝试从Android Studio中编写多个函数。我计划拥有多个云功能,并希望确保我的数据结构是正确的。以下是我的当前设置:

index.js

const functions = require('firebase-functions');
const trackVote = require('./trackVote')
const trendingCopy = require('./trendingCopy')
const admin = require('firebase-admin');
admin.initializeApp();



exports.trackVote = functions.firestore.document('Polls/{pollId}/responses/{userId}').onCreate(trackVoteModule.handler);
exports.trendingCopy = functions.firestore.document('Polls').onCreate(trendingCopyModule.handler);
跟踪投票:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();


exports.handler = (change, context => {

       const data = change.after.data();
       const answerSelected = data.answer;

       const answerRef = admin.firestore().doc(`Polls/${event.params.pollId}/answers/${answerSelected}`);
       const voteCountRef = admin.firestore.doc(`Polls/${event.params.pollId}/vote_count`);

        return admin.firestore().runTransaction(t => {
                    return t.get(answerRef)
                        .then(doc => {
                            if (doc.data()) {
                                t.update(answerRef, { vote_count: doc.data().vote_count + 1 });
                            }
                        })
                };
          //TODO DO NOT ADD TO GIT
         return admin.firestore().runTransaction(t => {
            return t.get(voteCountRef)
                .then(doc =>){
                    if (doc.data()){
                        t.update(voteCountRef, {vote_count:doc.data().vote_count+1});
                    }
                }
         });

});

    });
下面是我的控制台:

错误:函数预部署错误:命令以非零退出代码1终止


编辑:我认为这是一个建议的解决方案,但它提供了多种选择,并且不确定最佳实践:

组织云功能有一些可能性,但这里[在您提到的GitHub讨论中有一篇很好的帖子,它提供了一种很好的方式来组织您的云功能。谢谢-我在访问该页面时收到了一个404错误。抱歉,这里是:谢谢我将回顾-感谢您的帮助!