Firebase deploy errors starting with non-zero exit code (space in project path)

"predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ]

I remove that on firebase.json finally, it started to deploy again


What happens actually is that in Windows, firebase.json contains the following by default:

"predeploy": [
  "npm --prefix \"$RESOURCE_DIR\" run lint"
]

Modify it to:

"predeploy": [
  "npm --prefix \"%RESOURCE_DIR%\" run lint"
]

It worked for me, hope it works for you.


For me, none of the above worked. Initially, on a fresh firebase-function install, I was getting error on non-zero exit code2. so I removed the functions directory, re-installed, but on the functions directory configuration step, I chose to say "no" to the add-lint step.

once I chose to not include lint, I got error non-zero exit code1.

from there checked my firebase.json file and looked at the predeploy script. because the deployment process was failing at this point, it was where I started. my firebase.json file looked like this:

{
    "functions": {
        "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ]
    }
}

for some reason I intuitively thought to remove the lint in the predeploy script. this fixed everything. Im on MacOS by the way..


The error stems from the fact that you have a space somewhere in the path of your project ("Google Drive"):

C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json

Unfortunately, this is confusing the npm command line, and it's taking that as two arguments separated by that space.

Normally, I would expect to be able to place quotes around the whole thing to keep the space from being interpreted that way. So I tried this:

"predeploy": [
  "npm --prefix \"%RESOURCE_DIR%\" run lint"
]

And it works for me.

I'll follow up with the Firebase team internally about this issue, as well as the fact that changes need to be made for Windows.