云功能Node.js仿真器无法部署功能 - 找不到模块

问题描述 投票:0回答:1

我一直在阅读每篇文章都没有成功。我正在尝试使用nodejs模拟器在本地运行我的Firebase云功能代码。我按照官方docs中的步骤操作,但是在部署我的函数'helloworld'之后我得到了以下错误(函数deploy helloWorld --trigger-http)

ERROR: Function load error: Code could not be loaded.
ERROR: Does the file exists? Is there a syntax error in your code?
ERROR: Detailed stack trace: internal/modules/cjs/loader.js:584
    throw err;
    ^

Error: Cannot find module 'c:/Users/Ezequiel/Desktop/galum/functions'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at [eval]:1:40
    at Script.runInThisContext (vm.js:119:20)
    at Object.runInThisContext (vm.js:326:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at evalScript (internal/bootstrap/node.js:589:27)

ERROR: Error: Failed to deploy function.
    at exec (c:\Users\Ezequiel\AppData\Roaming\npm\node_modules\@google-cloud\fu
nctions-emulator\src\cli\controller.js:126:22)
    at ChildProcess.exithandler (child_process.js:301:5)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

请注意,我位于放置index.js的项目文件夹中。

firebase google-cloud-firestore google-cloud-functions
1个回答
0
投票

您应该在index.js存在的目录中运行deploy命令。

如果是以下页面,则将其命名为helloWorld

https://github.com/GoogleCloudPlatform/cloud-functions-emulator/

.
└── helloWorld
    └── index.js
cd helloWorld
functions-emulator start
functions-emulator deploy helloWorld --trigger-http
functions-emulator call helloWorld
functions-emulator logs read
functions-emulator stop
© www.soinside.com 2019 - 2024. All rights reserved.