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

点点圈 提交于 2019-11-27 20:07:50

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.

Spyde

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.

This what work for me after change $RESOURCE_DIR to %RESOURCE_DIR% in firebase.json

{
  "functions": {
    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint",
      "npm --prefix \"%RESOURCE_DIR%\" run build"
    ]
  }
}
Aditya Tandon

I had the same problem in Windows. What I did was I copied all the files which were in functions folder and passed it to %RESOURCE_DIR% folder and then I run the Firebase deploy and it deployed successfully.

For me, the issue was (I presume) because firebase couldn't find the script.

Didn't work:

{
  "hosting": {
    "predeploy": "predeploy.sh",
    ...
}
Running command: predeploy.sh
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn predeploy.sh ENOENT
    at exports._errnoException (util.js:1020:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3

Error: hosting predeploy error: Command terminated with non-zero exit code1

Did work: (note the ./)

{
  "hosting": {
    "predeploy": "./predeploy.sh",
    ...
}

When Using VS code ,open folder of Firecast (this helps open firebase.json of Resource Directory ) In firebase.json change the code of file to this:

{
  "functions": {
    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint",
      "npm --prefix \"%RESOURCE_DIR%\" run build"
    ]
  }
}

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

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

In my case I created a function to print logs, something like this:

function log(tag: string, value: any) {
    console.log(tag, JSON.stringify(value));
}

When I add async in front of it, it starts exploding the build :)

Inside the functions folder of the project run npm install. Maybe you are importing one or more node modules in index.ts that is not installed, in this case you need to run npm install module_not_installed_yet --save

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!