首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在本地运行firebase触发器事件

问在本地运行firebase触发器事件
EN

Stack Overflow用户
提问于 2020-05-02 02:59:29
回答 1查看 369关注 0票数 0

我有一个简单的方法,比如

代码语言:javascript
复制
exports.updatePlayer = functions.firestore
  .document('matches/{docId}')
  .onCreate((change, context) => {
    console.log('fired------------', context.params.docId);
  });

如果我将一个新文档添加到matches,我可以在日志中看到控制台消息。

问题是我如何在本地运行它?我在package.json里有这个命令

代码语言:javascript
复制
"serve": "firebase emulators:start --only functions,database",

当我运行‘`npm run server’时,控制台显示

代码语言:javascript
复制
> functions@ serve D:\cric\fs-functions\functions
> firebase emulators:start --only functions,database

i  emulators: Starting emulators: functions
!  database: Not starting the database emulator, make sure you have run firebase init.
+  hub: emulator hub started at http://localhost:4400
!  Your requested "node" version "8" doesn't match your global version "12"
+  functions: functions emulator started at http://localhost:5001
i  functions: Watching "D:\cric\fs-functions\functions" for Cloud Functions...
!  functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
+  functions[allMatches]: http function initialized (http://localhost:5001/xxxx-xxxxx/us-central1/allMatches).
i  functions[updatePlayer]: function ignored because the firestore emulator does not exist or is not running.
+  emulators: All emulators started, it is now safe to connect.

但是现在,如果我向firestore集合中添加了一些内容,我的本地终端上将不会收到任何控制台消息。也不是那个i functions[updatePlayer]: function ignored because the firestore emulator does not exist or is not running.

我想在本地运行这个触发器,这样就可以快速编写/测试我的代码。

EN

回答 1

Stack Overflow用户

发布于 2020-05-23 00:49:40

尝试更新您的NodeJs版本

Firebase宣布在云函数上弃用Node.js 8运行时,并停止使用Node.js 6运行时。

要确保您的函数位于受支持的Node.js版本上,请尽快迁移到Node.js 10运行时。

从Node.js 8更新到Node.js 10,通过setting the engines field in package.json显式指定Node.js 10运行时

NodeJs End-of-Life Releases

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61549003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档