Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 为什么“firebase服务”错误为“HTTP错误:400,请求包含无效参数”?_Node.js_Firebase_Google Cloud Firestore_Google Cloud Functions_Firebase Cli - Fatal编程技术网

Node.js 为什么“firebase服务”错误为“HTTP错误:400,请求包含无效参数”?

Node.js 为什么“firebase服务”错误为“HTTP错误:400,请求包含无效参数”?,node.js,firebase,google-cloud-firestore,google-cloud-functions,firebase-cli,Node.js,Firebase,Google Cloud Firestore,Google Cloud Functions,Firebase Cli,我试图在本地测试新函数 项目文件结构为: App/ typescript_functions/ flutter_web_app/ .firebaserc firebase.json firestore.indexes.json firestore.rules App/ typescript_functions/ flutter_web_app/ .firebaserc firebase.json firestore.indexe

我试图在本地测试新函数

项目文件结构为:

App/
   typescript_functions/
   flutter_web_app/
   .firebaserc
   firebase.json
   firestore.indexes.json
   firestore.rules
App/
   typescript_functions/
   flutter_web_app/
   .firebaserc
   firebase.json
   firestore.indexes.json
   firestore.rules
运行:
firebase服务--仅来自应用程序/或功能的功能/

返回:
错误:HTTP错误:400,请求包含无效参数。

这是某种身份验证错误吗

我从
node@12
node@8

node -v
v8.16.2
我已确保我的
.bash_配置文件
.zshrc
节点
npm
的路径正确无误。如果有帮助的话,我可以发布这些文件

我已经运行了
firebase注销
,然后
firebase登录
,没有任何问题。我可以访问
https://console.firebase.google.com
没有问题

我已退出终端,并在降级节点后重新打开它

我已经关闭并重新启动了我的计算机

项目文件结构为:

App/
   typescript_functions/
   flutter_web_app/
   .firebaserc
   firebase.json
   firestore.indexes.json
   firestore.rules
App/
   typescript_functions/
   flutter_web_app/
   .firebaserc
   firebase.json
   firestore.indexes.json
   firestore.rules
应用程序内/ firebase.json:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  },
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
    ]
  }
}
在功能上/ package.json:

{
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "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": {
    "@types/puppeteer": "^1.20.2",
    "algoliasearch": "^3.35.0",
    "axios": "^0.19.0",
    "dotenv": "^8.2.0",
    "firebase-admin": "^8.0.0",
    "firebase-functions": "^3.1.0",
    "puppeteer": "^1.20.0"
  },
  "devDependencies": {
    "@types/algoliasearch": "^3.34.3",
    "@types/dotenv": "^6.1.1",
    "jest-puppeteer": "^4.3.0",
    "tslint": "^5.12.0",
    "typescript": "^3.2.2"
  },
  "private": true
}

运行
firebase服务--仅函数--调试

返回:

相反,我得到了
错误:HTTP错误:400,请求包含无效参数。


有人知道我哪里出错了吗?

运行
firebase Service--仅限函数--debug
显示项目名称的第一个单词用于检查权限,而不是项目ID

我的解决方案是运行
gcloud组件更新
firebase注销
firebase登录
,然后
firebase使用[projectID]


我不知道注销和登录是必要的,但我试图覆盖所有基础。

运行
firebase-server--仅限函数--debug
显示项目名称的第一个单词用于检查权限,而不是项目ID

我的解决方案是运行
gcloud组件更新
firebase注销
firebase登录
,然后
firebase使用[projectID]


我不知道注销和登录是必要的,但我试图涵盖所有基本问题。

请编辑问题,以包括您试图运行的代码的问题。@DougStevenson,我整个上午都在尝试创建MCVE失败。但我发现一件有趣的事情是,GCloud和/或Cloud IAM不知何故使用了项目名称的第一个单词,而不是项目ID。我正在试图弄清楚为什么会发生这种情况。我创建了另一个按预期工作的项目,包括GCloud和Cloud IAM。请编辑问题,以包括您试图运行的代码的问题。@DougStevenson,我整个上午都在尝试创建MCVE失败。但我发现一件有趣的事情是,GCloud和/或Cloud IAM不知何故使用了项目名称的第一个单词,而不是项目ID。我正在试图弄清楚为什么会发生这种情况。我创建了另一个按预期工作的项目,包括GCloud和cloudiam。
[2019-10-23T02:06:29.461Z] ----------------------------------------------------------------------
[2019-10-23T02:06:29.464Z] Command:       /usr/local/Cellar/node@8/8.16.2/bin/node /usr/local/bin/firebase serve --only functions --debug
[2019-10-23T02:06:29.465Z] CLI Version:   7.6.1
[2019-10-23T02:06:29.465Z] Platform:      darwin
[2019-10-23T02:06:29.465Z] Node Version:  v8.16.2
[2019-10-23T02:06:29.465Z] Time:          Tue Oct 22 2019 19:06:29 GMT-0700 (PDT)
[2019-10-23T02:06:29.465Z] ----------------------------------------------------------------------
[2019-10-23T02:06:29.466Z] 
[2019-10-23T02:06:29.473Z] > 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"]
[2019-10-23T02:06:29.474Z] > authorizing via signed-in user
[2019-10-23T02:06:29.474Z] [iam] checking project [PROJECT] for permissions ["firebase.projects.get"]
[2019-10-23T02:06:29.476Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/[PROJECT]:testIamPermissions  
 permissions=[firebase.projects.get]
[2019-10-23T02:06:29.609Z] <<< HTTP RESPONSE 400 vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Wed, 23 Oct 2019 02:06:29 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=59, alt-svc=quic=":443"; ma=2592000; v="46,43",h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000, accept-ranges=none, transfer-encoding=chunked
[2019-10-23T02:06:29.610Z] <<< HTTP RESPONSE BODY code=400, message=Request contains an invalid argument., status=INVALID_ARGUMENT

Error: HTTP Error: 400, Request contains an invalid argument.
[2019-10-23T02:06:29.673Z] Error Context: {
  "body": {
    "error": {
      "code": 400,
      "message": "Request contains an invalid argument.",
      "status": "INVALID_ARGUMENT"
    }
  },
  "response": {
    "statusCode": 400,
    "body": {
      "error": {
        "code": 400,
        "message": "Request contains an invalid argument.",
        "status": "INVALID_ARGUMENT"
      }
    },
    "headers": {
      "vary": "X-Origin, Referer, Origin,Accept-Encoding",
      "content-type": "application/json; charset=UTF-8",
      "date": "Wed, 23 Oct 2019 02:06:29 GMT",
      "server": "ESF",
      "cache-control": "private",
      "x-xss-protection": "0",
      "x-frame-options": "SAMEORIGIN",
      "x-content-type-options": "nosniff",
      "server-timing": "gfet4t7; dur=59",
      "alt-svc": "quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000",
      "accept-ranges": "none",
      "transfer-encoding": "chunked"
    },
    "request": {
      "uri": {
        "protocol": "https:",
        "slashes": true,
        "auth": null,
        "host": "cloudresourcemanager.googleapis.com",
        "port": 443,
        "hostname": "cloudresourcemanager.googleapis.com",
        "hash": null,
        "search": null,
        "query": null,
        "pathname": "/v1/projects/[PROJECT]:testIamPermissions",
        "path": "/v1/projects/[PROJECT]:testIamPermissions",
        "href": "https://cloudresourcemanager.googleapis.com/v1/projects/[PROJECT]:testIamPermissions"
      },
      "method": "POST"
    }
  }
}
curl "http://localhost:5000/project-name/us-central1/runMyFunction?someDocumentId=some-someDocumentId-hash&anotherDocumentId=some-anotherDocumentId-hash"