Firebase的云功能无法模拟

时间:2018-03-31 16:02:37

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

当我尝试运行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 Framework上。它与此有关吗?

环境:

  • 在MacOS High Sierra上运行
  • Node.js v6.11.5
  • NPM版本3.10.10
  • firebase-tools:3.17.7(全局)
  • firebase-admin:^ 5.11.0,
  • firebase-functions:^ 0.9.1

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

尝试使用其他端口。例子

firebase serve --port 3000 --only functions