Firebase的云功能无法模拟

Eli*_*hen 10 node.js firebase google-cloud-functions

当我尝试运行时npm run serve:

"build": "./node_modules/.bin/tsc",
"serve": "npm run build && firebase serve --only functions",
Run Code Online (Sandbox Code Playgroud)

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

> 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
Run Code Online (Sandbox Code Playgroud)

当我打开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
Run Code Online (Sandbox Code Playgroud)

据我所知,它无法达到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

Eli*_*hen 0

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