Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firebase deploy Error: functions predeploy error: Command terminated with non-zero exit code 2

I'm starting to learn how to use google cloud function. I tried the firebase deploy command

firebase deploy

but got the following error:

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

This is my package.json file.

{
  "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
}

And this is the file my firebase.json

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

I've been trying to find a solution. And the project has been upgraded to Bronze plan. But couldn't fix it at all. Now I'm really helpless. Thank you everyone for your help.

I've tried editing various threads. that has already been recommended But still unable to use firebase deploy command.

like image 218
birdbluez Avatar asked Dec 18 '25 12:12

birdbluez


2 Answers

According to this discussion, this could be caused by using the curl installed version of firebase-cli.

Uninstalling that:

curl -sL firebase.tools | uninstall=true bash

and re-installing via Homebrew resolved the issue for me

brew install firebase-cli

The solution above also notes that the npm installation works:

npm install -g firebase-tools
like image 149
muya_ Avatar answered Dec 20 '25 07:12

muya_


I was using node 16. It worked just by switching to node v20.

like image 22
gmotzespina Avatar answered Dec 20 '25 07:12

gmotzespina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!