【问题标题】:Get "HTTP Error: 404, Method not found." when running "firebase deploy --only functions" on Firebase Cloud Functions获取“HTTP 错误:404,找不到方法。”在 Firebase Cloud Functions 上运行“firebase deploy --only functions”时
【发布时间】:2020-12-14 09:30:48
【问题描述】:

几个小时以来我一直被这个问题困扰,我想也许你们中的一个人以前遇到过。

我明白了 Error: HTTP Error: 404, Method not found. 当我运行 firebase deploy --only functions 时,我无法部署我的最新更新。

  • 所有我的 Firebase Cloud Functions 项目都会发生这种情况

  • 我的 Firebase 主机不会发生这种情况

这是我添加 --debug 后得到的结果:

firebase deploy --only functions:onBookingCreated --debug
[2020-08-25T15:18:37.029Z] ----------------------------------------------------------------------
[2020-08-25T15:18:37.032Z] Command:       /usr/local/Cellar/node/12.4.0/bin/node /usr/local/bin/firebase deploy --only functions:onBookingCreated --debug
[2020-08-25T15:18:37.032Z] CLI Version:   7.0.0
[2020-08-25T15:18:37.032Z] Platform:      darwin
[2020-08-25T15:18:37.032Z] Node Version:  v10.15.3
[2020-08-25T15:18:37.033Z] Time:          Tue Aug 25 2020 17:18:37 GMT+0200 (Central European Summer Time)
[2020-08-25T15:18:37.034Z] ----------------------------------------------------------------------

[2020-08-25T15:18:37.044Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-08-25T15:18:37.044Z] > authorizing via signed-in user
[2020-08-25T15:18:37.044Z] [iam] checking project infinitytechnologies for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2020-08-25T15:18:37.046Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/infinitytechnologies:testIamPermissions  
 permissions=[cloudfunctions.functions.create, cloudfunctions.functions.delete, cloudfunctions.functions.get, cloudfunctions.functions.list, cloudfunctions.functions.update, cloudfunctions.operations.get, firebase.projects.get]
[2020-08-25T15:18:37.814Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Tue, 25 Aug 2020 15:18:42 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=622, alt-svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43", accept-ranges=none, transfer-encoding=chunked

=== Deploying to 'infinitytechnologies'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run build

> functions@ build /Users/Ben/infinitytechnologies-functions/functions
> tsc

✔  functions: Finished running predeploy script.
[2020-08-25T15:18:48.982Z] > [functions] package.json contents: {
  "name": "functions",
  "scripts": {
    "build": "tsc",
    "buildRun": "tsc -w",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "8"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/logging-winston": "^3.0.5",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "firebase": "^7.19.0",
    "firebase-admin": "^8.13.0",
    "firebase-functions": "^3.0.0",
    "googleapis": "^43.0.0",
    "html-encoder-decoder": "^1.3.8",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.27",
    "morgan": "^1.9.1",
    "morgan-body": "^2.4.8",
    "node-mailjet": "3.3.1",
    "telegraf": "^3.30.1",
    "tmp": "^0.1.0",
    "winston": "^3.2.1"
  },
  "devDependencies": {
    "@types/moment-timezone": "^0.5.12",
    "typescript": "^3.7.4"
  },
  "private": true
}
i  functions: ensuring necessary APIs are enabled...
[2020-08-25T15:18:48.983Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW  
 
[2020-08-25T15:18:48.984Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW  
 
[2020-08-25T15:18:49.689Z] <<< HTTP RESPONSE 404 x-debug-tracking-id=15822584760350287123;o=0, vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Tue, 25 Aug 2020 15:18:54 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, alt-svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43", accept-ranges=none, transfer-encoding=chunked
[2020-08-25T15:18:49.689Z] <<< HTTP RESPONSE BODY code=404, message=Method not found., status=NOT_FOUND

Error: HTTP Error: 404, Method not found.
[2020-08-25T15:18:49.692Z] Error Context: {
  "body": {
    "error": {
      "code": 404,
      "message": "Method not found.",
      "status": "NOT_FOUND"
    }
  },
  "response": {
    "statusCode": 404,
    "body": {
      "error": {
        "code": 404,
        "message": "Method not found.",
        "status": "NOT_FOUND"
      }
    },
    "headers": {
      "x-debug-tracking-id": "15822584760350287123;o=0",
      "vary": "X-Origin, Referer, Origin,Accept-Encoding",
      "content-type": "application/json; charset=UTF-8",
      "date": "Tue, 25 Aug 2020 15:18:54 GMT",
      "server": "ESF",
      "cache-control": "private",
      "x-xss-protection": "0",
      "x-frame-options": "SAMEORIGIN",
      "alt-svc": "h3-29=\":443\"; ma=2592000,h3-27=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"",
      "accept-ranges": "none",
      "transfer-encoding": "chunked"
    },
    "request": {
      "uri": {
        "protocol": "https:",
        "slashes": true,
        "auth": null,
        "host": "servicemanagement.googleapis.com",
        "port": 443,
        "hostname": "servicemanagement.googleapis.com",
        "hash": null,
        "search": "?view=CONSUMER_VIEW",
        "query": "view=CONSUMER_VIEW",
        "pathname": "/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies",
        "path": "/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW",
        "href": "https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW"
      },
      "method": "GET"
    }
  }
}
[2020-08-25T15:18:49.693Z] <<< HTTP RESPONSE 404 x-debug-tracking-id=13898179262678311641;o=0, vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Tue, 25 Aug 2020 15:18:54 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, alt-svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43", accept-ranges=none, transfer-encoding=chunked
[2020-08-25T15:18:49.693Z] <<< HTTP RESPONSE BODY code=404, message=Method not found., status=NOT_FOUND

感谢您的帮助! :)

【问题讨论】:

    标签: google-cloud-functions firebase-cli


    【解决方案1】:

    我有同样的问题。我安装了 NodeJS 12.18,然后在下面的命令中触发了

    npm install -g firebase firebase-tools
    firebase init functions
    

    然后将所有代码文件复制到这个新的函数文件夹中。用必要的包更新了 package.json。这解决了我的问题。

    【讨论】:

      【解决方案2】:

      感谢您这么快回答!

      我试图这样做,但我明白了:

      (base) Ben MBP:functions Ben$ npm install -g firebase-tools
      npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
      npm WARN deprecated har-validator@5.1.5: this library is no longer supported
      /usr/local/Cellar/node/14.8.0/bin/firebase -> /usr/local/Cellar/node/14.8.0/lib/node_modules/firebase-tools/lib/bin/firebase.js
      npm WARN ws@7.3.1 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
      npm WARN ws@7.3.1 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
      
      + firebase-tools@8.9.0
      updated 1 package in 10.942s
      (base) Ben MBP:functions Ben$ firebase -V
      7.0.0
      

      所以问题出在 brew 及其 Cellar 文件夹上。我不知道为什么,但它不能正常工作。

      所以我刚刚删除了 Cellar 文件夹,手动重新安装了节点(不使用 brew),我可以更新 firebase-tools,现在一切正常!

      感谢您的帮助!

      【讨论】:

        【解决方案3】:

        您使用的是非常旧的 Firebase CLI 版本 (7.0.0)。最新的是 8.9.0。按照instructions进行升级安装。如果您使用 npm 安装,则只需运行 npm i -g firebase-tools。您应该努力使其随着时间的推移保持最新,因为它经常变化。

        【讨论】:

        • 感谢您的好回答对我帮助很大。
        猜你喜欢
        • 2018-06-11
        • 1970-01-01
        • 2018-04-19
        • 2019-10-01
        • 1970-01-01
        • 2018-06-17
        • 2018-09-08
        • 2020-12-04
        • 2020-10-01
        相关资源
        最近更新 更多