Google Cloud Function - Function load error: File main.py that is expected to define function doesn't exist

前端 未结 5 1213
渐次进展
渐次进展 2021-01-04 16:36

I am trying to implement a Google Cloud function that is based on code in a Git style repository. I have the code linked to Google Cloud Platform\'s \"Source Repositories\"

5条回答
  •  猫巷女王i
    2021-01-04 16:55

    I had a similar (possibly same?) problem. What happened with me is that all my files were in the format:

    1. [zip file name]/main.py
    2. [zip file name/[etc.]

    and the error kept saying it could not find main. I was guessing that this was because it had a parent folder. After looking at zipping into the parent for a bit I determined it wasn't the issue.

    I downloaded the zip of and looked at autogenerated dialogflow cloud function code and noticed they had a "package.json" file. I instead just had a "requirements.txt" file. I copied the package.json file to my source code, editted it for the correct contents, zipped it, and the cloud function compiled correctly.

    package.json looks like:

    {
      "name": "test",
      "description": "testingThings",
      "version": "0.0.1",
      "private": true,
      "license": "Apache Version 2.0",
      "author": "ABCDEFG",
      "engines": {
        "node": "8"
      },
      "scripts": {
        "start": "firebase serve --only functions:test",
        "deploy": "firebase deploy --only functions:test"
      },
      "dependencies": {
        "google-cloud-storage": "",
        "google-cloud-firestore": "",
      }
    }
    

    I believe they use this for deploying the google cloud functions so without it they break.

提交回复
热议问题