firebase 部署错误:函数预部署错误:命令以非零退出代码 2 终止

bir*_*uez 7 node.js google-cloud-functions

我开始学习如何使用谷歌云功能。我尝试了 firebase 部署命令

firebase deploy

但出现以下错误:

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

> lint
> eslint

/bin/sh: --: invalid option
Usage:  /bin/sh [GNU long option] [option] ...
        /bin/sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
        --wordexp
Shell options:
        -irsD or -c command or -O shopt_option          (invocation only)
        -abefhkmnptuvxBCHP or -o option

Error: functions predeploy error: Command terminated with non-zero exit code 2
Run Code Online (Sandbox Code Playgroud)

这是我的 package.json 文件。

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint",
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "18"
  },
  "main": "index.js",
  "dependencies": {
    "cors": "^2.8.5",
    "express": "^4.18.2",
    "firebase-admin": "^11.8.0",
    "firebase-functions": "^4.3.1"
  },
  "devDependencies": {
    "eslint": "^8.15.0",
    "eslint-config-google": "^0.14.0",
    "firebase-functions-test": "^3.1.0"
  },
  "private": true
}
Run Code Online (Sandbox Code Playgroud)

这是我的 firebase.json 文件

{
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ],
      "predeploy": [
        "npm --prefix \"$RESOURCE_DIR\" run lint"
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我一直在努力寻找解决方案。并且该项目已升级为Bronze计划。但根本无法修复。现在我真的很无助。感谢大家的帮助。

我尝试过编辑各种线程。已经推荐但仍然无法使用 firebase 部署命令。

gmo*_*ina 0

我使用的是节点 16。只需切换到节点 v20 即可。