【问题标题】:Cloud Functions of Firebase failed to emulateFirebase 的 Cloud Functions 无法模拟
【发布时间】:2018-09-10 09:34:42
【问题描述】:

当我尝试运行npm run serve:

"build": "./node_modules/.bin/tsc",
"serve": "npm run build && firebase serve --only functions",

我得到一个输出,说它无法模拟我的功能:

> npm run build && firebase serve --only functions


> functions@ build /Users/eliyacohen/apps/app-name/functions
> tsc


=== Serving from '/Users/eliyacohen/apps/app-name'...

i  functions: Preparing to emulate functions.
⚠  functions: Failed to emulate payment-create
⚠  functions: Failed to emulate payment-process

当我打开firebase-debug.log 了解更多信息时,我看到:

...
Sat Mar 31 2018 18:48:05 GMT+0300 (IDT)
[debug] [2018-03-31T15:48:06.665Z] <<< HTTP RESPONSE 200
[debug] [2018-03-31T15:48:06.666Z] Starting @google-cloud/functions-emulator
[debug] [2018-03-31T15:48:08.254Z] Parsing function triggers
[debug] [2018-03-31T15:48:10.194Z] Error while deploy to emulator: Error: connect ECONNREFUSED 127.0.0.1:5001
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
[debug] [2018-03-31T15:48:10.195Z] Error while deploy to emulator: Error: connect ECONNREFUSED 127.0.0.1:5001
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
[warn] ⚠  functions: Failed to emulate payment-create
[warn] ⚠  functions: Failed to emulate payment-process

据我了解,它无法到达 127.0.0.1:5001 所以它可以在本地提供这些功能?

我知道我的代码没有问题,因为 firebase deploy --only functions 部署我的函数时没有错误。

我尝试完全删除 Node.js 并重新安装、降级和升级它。全局模块也是如此。

我的主文件夹 (../functions) 是基于 Ionic 框架构建的。跟这个有关系吗?

环境:

  • 在 MacOS High Sierra 上运行
  • Node.js v6.11.5
  • NPM 版本 3.10.10
  • firebase 工具:3.17.7(全球)
  • firebase 管理员:^5.11.0,
  • firebase 功能:^0.9.1

【问题讨论】:

  • 您是否也尝试过重启?
  • 遇到同样的问题,当我从另一个较旧的 firebase 项目中复制并粘贴我的节点模块时,firebase 服务模拟了这些功能...... prob 应该在 github 上打开一个问题
  • 你们找到这个解决方案/更新了吗?一直在部署函数来测试它真的很伤心
  • @GuilhermeMatuella 尝试更新到节点 10,重新启动 pc,删除节点模块,然后再次 npm 安装。确保你的依赖是最新的
  • @Marco 看看 cmets。升级到最新版本的 nodejs 解决了这个问题。

标签: node.js firebase google-cloud-functions


【解决方案1】:

由于我看到很多人仍然遇到以下错误,请尝试将您的节点版本更新为最新的稳定版本(或 >= 10)

【讨论】:

    【解决方案2】:

    尝试使用不同的端口。例子

    firebase serve --port 3000 --only functions
    

    【讨论】:

    • 错误提示它无法连接到 emulator,这可能不是一个正确的答案 - 但一个很好的故障排除技术。
    猜你喜欢
    • 2017-09-01
    • 1970-01-01
    • 2019-09-27
    • 2020-02-01
    • 2023-03-11
    • 2019-07-21
    • 2021-04-22
    • 1970-01-01
    • 2022-07-28
    相关资源
    最近更新 更多