【问题标题】:Google Cloud Function Error "Function failed on loading user code." with Typescript Functions谷歌云函数错误“加载用户代码时函数失败。”带有打字稿功能
【发布时间】:2019-08-07 19:54:10
【问题描述】:

当我第一次使用 Typescript 创建 Google Cloud 函数时,我遇到了错误
Function failed on loading user code. Error message: Provided code is not a loadable module. Could not load the function, shutting down.

在我的 package.json 中,我将 main 属性指定为 "./build/app.js"

【问题讨论】:

    标签: typescript google-cloud-platform google-cloud-functions


    【解决方案1】:

    当您没有指定.gcloudignore 文件时会出现问题。 gcloud SDK 会尽力提供帮助,并为您提供一个。 该文件的最后有这一行:
    #!include:.gitignore
    我忽略了它,因为它看起来像注释行。对我来说是个坏主意。虽然我觉得这违反了最小惊讶原则,但如果您阅读自动生成文件的顶部,它会指出
    #!include:
    语法包括.gitcloudignore 文件中指定文件的内容。由于我不想将我的 build 文件夹添加到 git 中,这意味着它也不会上传到我的函数中。一旦兔子洞退出,很容易修复。只需从自动生成的.gcloudignore 文件中删除该行。

    【讨论】:

      猜你喜欢
      • 2021-11-06
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 1970-01-01
      • 2021-10-12
      • 1970-01-01
      • 2019-01-30
      相关资源
      最近更新 更多