当前位置: 首页 > 知识库问答 >
问题:

更新后Firebase-Functions出错。我能做什么?

章茂
2023-03-14

我更新了我的firebase-functions,现在我在Firebase控制台中发现了这个错误。代码仍然相同,但我现在得到一个错误:

/srv/node_modules/@google-cloud/firestore/build/src/collection-group.js:54
    async *getPartitions(desiredPartitionCount) {
          ^

SyntaxError: Unexpected token *
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    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 Object.<anonymous> (/srv/node_modules/@google-cloud/firestore/build/src/index.js:39:28)

这是我的云功能打字源:

import * as functions from 'firebase-functions';
import admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

/********************************************************************/

exports.newChatMessage = functions.firestore
  .document('/games/{gameId}/chat/{chatId}')
  .onCreate((snap, context) => {

    const createData = snap.data();
    if(!createData) {
        return false;
    }

    const chatMessage = createData.message;
    if(!chatMessage) {
        return false;
    }

    console.log('New Chat message in game: ', context.params.gameId);

    const payload = {
        notification: {
            title: 'New chat message',
            body: chatMessage,
            icon: 'ic_notification'
        }
    }

    return admin.firestore().collection(`/games/${context.params.gameId}/members`).where( 'notificationChat', '==', true ).get().then( members => {
        members.forEach( member => {
            if(member.id !== createData.user) {
                return admin.firestore().doc(`/users/${member.id}`).get().then( memberdata => {
                    if( memberdata.get('firebaseToken') === '' ) {
                        return memberdata.data();
                    } else {
                        return admin.messaging().sendToDevice(memberdata.get('firebaseToken'), payload).catch( error => { console.log(error) });
                    }
                }).catch( error => { console.log(error) });
            } else {
                return false;
            }
        })
    }).catch( error => { console.log(error) });

});

这是什么?在我的函数中没有任何名为*getpartitions的方法。

共有1个答案

赵兴朝
2023-03-14

将firebase-admin和firebase-functions降级到版本:“firebase-admin”:“^8.10.0”、“firebase-functions”:“^3.6.1”,它就可以工作了。

感谢Marcel Hoekstra在评论中发表了这篇文章。

 类似资料:
  • 我的android工作室刚刚更新了,之后我的应用程序就不能再编译了。它显示以下错误: 任务“:app:ProcessDebugManifest”执行失败。

  • 我对Firebase和Nodejs是新手。我正在尝试使用Firebase Cloud函数从一个设备发送通知到另一个设备。 这是发送通知的node.js代码: 这是将通知添加到实时数据库以触发函数的代码: 反应真的很清楚,代币已经改变了。我已经将它更改为有效的令牌,它起作用了。

  • 问题内容: 如果html文件是本地文件(在我的C驱动器上),则可以使用,但是如果html文件在服务器上并且图像文件是本地文件,则无法使用。这是为什么? 任何可能的解决方法? 问题答案: 如果客户端可以请求本地文件系统文件,然后使用JavaScript找出其中的内容,则将是一个安全漏洞。 解决此问题的唯一方法是在浏览器中构建扩展。Firefox扩展和IE扩展可以访问本地资源。Chrome的限制更为严

  • 最近我把我的Android Studio更新到3.6.1,没有出现任何问题,但是当Gradle完成同步时,一条错误消息就显示在我的构建和事件日志中。 (“build”消息内部) null --谢谢您提前回答。

  • 我正在做一个项目,我的意图是运行一个玉米作业,并发送邮件给我的朋友,祝他们生日,我能够从MySQL DB获取电子邮件,并将其与当前日期进行比较,但当涉及到发送电子邮件时,我得到NullPointerException。 我确信应用程序属性没有问题,我在其他项目中也使用了它们,它们的功能正常 这是我得到以下信息的错误

  • 嘿,伙计们,我最近将我的mac更新为最新的OS X 10.12.3以前我的rails项目运行良好,现在每当我启动rails服务器时,我的项目都会收到这个错误。我尝试了在stackoverflow中提供的很多不同的解决方案,但它仍然不起作用。 这里有一些我尝试过的 Postgres无法连接到服务器 PostgreSQL错误“无法连接到服务器:没有这样的文件或目录” 谢谢,请帮帮我