firebase - Cloud Functions Node.js Emulator 无法部署功能 - 找不到模块
问题描述
我一直在阅读每篇文章但没有成功。我正在尝试使用 nodejs 模拟器在本地运行我的 Firebase Cloud Functions 代码。我按照官方文档中的步骤进行操作,但在部署函数“helloworld”后出现以下错误(函数部署 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 的项目文件夹中。
解决方案
您应该在您index.js
存在的目录中运行部署命令。
在以下页面的情况下,它命名为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
推荐阅读
- python - 如何在 Python-3.7 中修复 Tkinter?
- arrays - 为什么 - 会以正数返回正数?
- html - 我正在使用箭头键(向上,向下)导航 html,焦点将转到每个 div 元素。我想跳过html页面中一个div元素的焦点
- android - 从膨胀的 XML 将适配器设置为 ListView 以打印 PDF - 缺少项目
- react-native - 如何使用 wix react-native-navigation 获得 bottomTab 按下操作?
- python - 不允许空格和除下划线以外的特殊符号的正则表达式
- salesforce - 谷歌表单与Salesforce集成
- r - 如何在不显示图例的情况下使用 fviz_pca_ind() 进行绘图?
- javascript - 如何使用 MediaSource API 播放音频?
- c# - 无法通过 ASP.NET Identity 3.0 中的 Http 发布请求删除用户