I upgrade to firebase-tools 6.3.0 and when I deploy to hosting, it is not running my predeploy scripts. In specific I am running sass and webpack. I downgraded to 6.2.0 and everything works fine.
firebase-tools: 6.3.0
Platform: macOS
Run firebase deploy --only hosting
"predeploy" scripts should run.
"predeploy" scripts are not running.
Can you provide your firebase.json or the relevant parts? I just tried this locally and my predeploy ran as expected.
Absolutely, I don't think there is anything fancy going on.
Actually I just double checked, the rm command is working, but sass and webpack is not working, which is why I noticed the issue. My assets were gone and never repopulated when I deployed.
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "functions"
},
"hosting": {
"predeploy": [
"rm -f hosting/public/assets/index.js hosting/public/assets/index.js.map hosting/public/assets/vendors.index.js hosting/public/assets/vendors.index.js.map hosting/public/assets/style.css hosting/public/assets/style.css.map",
"sass --style=compressed --no-source-map hosting/scss/style.scss:hosting/public/assets/style.css",
"webpack --env=production --config=hosting/webpack.config.js --context=hosting"
],
"public": "hosting/public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"firestore": {
"rules": "firestore.rules"
}
}
What does your output look like when you deploy? Do you see Running command: sass --style=compressed --no-source-map hosting/scss/style.scss:hosting/public/assets/style.css? I just tried another test with multiple commands and they all ran.
Could it perhaps be an issue with not having the correct global modules installed? Wonder if you'd have more success by prepending npx to the last two commands.
@mbleigh Yes I do see Running command: ...
I tried using npx, but I am getting the same outcome.
My output looks like this...
i deploying hosting
Running command: rm -f hosting/public/assets/index.js hosting/public/assets/index.js.map hosting/public/assets/vendors.index.js hosting/public/assets/vendors.index.js.map hosting/public/assets/style.css hosting/public/assets/style.css.map
Running command: npx sass --style=compressed --no-source-map hosting/scss/style.scss:hosting/public/assets/style.css
Running command: npx webpack --env=production --config=hosting/webpack.config.js --context=hosting
โ hosting: Finished running predeploy script.
i hosting[atlas-wearables-stage]: beginning deploy...
i hosting[atlas-wearables-stage]: found 1 files in hosting/public
โ hosting[atlas-wearables-stage]: file upload complete
i hosting[atlas-wearables-stage]: finalizing version...
โ hosting[atlas-wearables-stage]: version finalized
i hosting[atlas-wearables-stage]: releasing new version...
โ hosting[atlas-wearables-stage]: release complete
โ Deploy complete!
Does running the command do what you expect outside of running it as part of a deploy? What if you added something like && echo 'hello world' to the end of each command that isn't running correctly? That would tell you whether the command is running and silently succeeding without doing what you expect.
Yes it works outside of deploy, that's how I was able to get it to work. Also it works with firebase-tools 6.2.0.
That's a good idea: looks like it's not executing the echo.
i deploying hosting
Running command: rm -f hosting/public/assets/index.js hosting/public/assets/index.js.map hosting/public/assets/vendors.index.js hosting/public/assets/vendors.index.js.map hosting/public/assets/style.css hosting/public/assets/style.css.map && echo 'hello world 1'
hello world 1
Running command: sass --style=compressed --no-source-map hosting/scss/style.scss:hosting/public/assets/style.css && echo 'hello world 2'
Running command: webpack --env=production --config=hosting/webpack.config.js --context=hosting && echo 'hello world 3'
โ hosting: Finished running predeploy script.
Also I tried running 3 simple commands. Looks like that's working...
i deploying hosting
Running command: echo 'hello world 1'
hello world 1
Running command: echo 'hello world 2'
hello world 2
Running command: echo 'hello world 3'
hello world 3
โ hosting: Finished running predeploy script.
I tried deleting the sass command, and the webpack command, but same outcome. I also tried running the sass and webpack (without rm) command by itself and they don't work.
It seems like it's silently failing the commands...but perhaps returning a success exit code? I'm at a bit of a loss as to what to ask you to try next, because I haven't been able to replicate this behavior. Are there any flags you can add to the sass/webpack commands to make them more verbose? If you do sass ... || echo "hello world" does that output?
Hey @nickgzzjr. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@nickgzzjr if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
I'm seeing a similar issues since updating to version 6.3.0
I have been setting a variable and passing it into a script (simplified example of my use case below).
"predeploy": [
"TEST=123 && echo $TEST"
]
I've added a console log to see the translated command, which seems to be fine, but it doesn't actually attempt to execute the echo (or anything I try). I have a feeling it's something to do with some characters like '$' in my case or ':' in @nickgzzjr case.

It's not my exact issue, but I'm finding similar bug reports on the cross-env library that firebase tools is using https://github.com/kentcdodds/cross-env/issues/192
Actually, it works for me on v6.2.2 but since v6.3.0 it hasn't executed properly.
I think it has something to do with the regex introduced here https://github.com/firebase/firebase-tools/compare/v6.2.2...v6.3.0#diff-14e512e4127bbadd8843e44146995faa
My previous example probably isn't the best, my real example is:
"predeploy": [
"FIREBASE_PROJECT=$(firebase use) npm run setup-functions-config"
]
where my package.json has:
"scripts": {
...
"setup-functions-config": "ts-node config-generator.ts",
...
},
which uses process.env.FIREBASE_PROJECT within the typescript program.
Ah, there was a change from cross-env.js to cross-env-shell.js at that time. Looking at their README, variable assigning works differently ๐ค
Found the PR: https://github.com/firebase/firebase-tools/pull/1068
@abehaskins oops, but you caught us ๐
Any tips on how we can set an environment variable and then execute an npm script since v6.3.0?
Also, @abehaskins the change caused one of our very important predeploy scripts that we use to setup configurations in CI to silently not execute. It was very lucky that we caught it in our local environment, perhaps it's worthy of a warning or throwing an error in the next tools release if possible.
Your PR comment reminded me of this ๐

Worked around it by moving the variable assigning into the npm script, which isn't ideal but will do for now.
Anyone still having the original issue I was having, a good work around is to use npm scripts.
Exactly the same problem, predeploy isn't executed automatically anymore. We have to execute it explicitly in the CI's, at least it was my case with GitLab CI.
I was using npm scripts to do my predeploy but my npm command was silently failing when setting envs before the command. After removing my variables set before the command (ENV=.. npm run ...) the error became apparent again.
I was using npm --prefix \"$RESOURCE_DIR\" run predeploy but hosting targets with the "public": "app/dist" the RESOURCE_DIR is set to that folder which is not the module root in my case. Hence npm --prefix \"$RESOURCE_DIR\"/.. run predeploy -- ...args
Most helpful comment
Your PR comment reminded me of this ๐
