Ber*_*lue 5 node.js firebase google-cloud-functions
我尝试将一些先前运行的云功能更新到 Firebase,但遇到了奇怪的错误。这些是我的主文件中每个函数遇到的错误index.js
。
Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Run Code Online (Sandbox Code Playgroud)
当我查看日志时,我看到这些错误。
Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging Function cannot be initialized.
Run Code Online (Sandbox Code Playgroud)
下一个建议资源中的文档非常通用。如何进行额外的日志记录来查找问题?我可以在本地正常运行我的代码,所以我不确定为什么它不会部署到 Firebase。
我相信问题可能是因为需要 JSON 文件作为模块。这在本地工作正常,但 Firebase 支持此功能吗?
const config = require('./config.json');
Run Code Online (Sandbox Code Playgroud)
Jer*_*der 13
抱歉我的英语不好,我说西班牙语,但我会尽力让你听懂我的意思。
我不是 NodeJS 专家,但我遇到了同样的错误,我的问题是我在“devDependency”中添加了依赖项,但它们必须继续“依赖项”,然后我们进入项目“functions”(如果是 firebase )并在控制台中执行下一个命令npm i
,然后npm ci
在完成所有这些操作后,我们将正常进行部署。
您可以看到完整的日志:在控制台中执行下一个命令firebase functions:log --only nameYourFunction
并搜索下一句“详细堆栈跟踪:错误:找不到模块”
然后它会告诉您哪个模块有冲突,并且日志包含更多信息。
参考:
https://docs.npmjs.com/cli/v7/commands/npm-ci
https://github.com/npm/npm/issues/16866
归档时间: |
|
查看次数: |
5822 次 |
最近记录: |