Firebase "Specified public directory 'public' does not exist" in CI
The hosting public folder named in firebase.json does not exist on the runner. In CI this almost always means the build step did not run, ran in a different directory, or wrote output somewhere else.
What this error means
A hosting deploy fails with "Error: Specified public directory 'public' does not exist, can't deploy hosting to site".
firebase
Error: Specified public directory 'public' does not exist, can't deploy hosting to site my-siteCommon causes
The build step did not run before deploy
The deploy ran before npm run build, so the output directory the config points at was never produced.
The build output path differs from firebase.json
The framework writes to dist or build but firebase.json still names public, so the CLI finds no folder.
How to fix it
Build before deploying
- Run the build step so the output directory exists.
- Confirm the directory name matches
hosting.publicinfirebase.json. - Then run the hosting deploy.
Terminal
npm ci
npm run build
firebase deploy --only hosting --project my-projectAlign the public path with the build output
Set hosting.public to the folder your framework actually emits.
firebase.json
{
"hosting": { "public": "dist" }
}How to prevent it
- Always build before the hosting deploy in the same job.
- Keep
hosting.publicin sync with the framework output directory. - Fail the job if the output directory is empty before deploying.
Related guides
Firebase "Cannot understand what targets to deploy/serve" in CIFix Firebase "Error: Cannot understand what targets to deploy/serve" in CI - firebase.json has no matching pr…
Firebase hosting "Must supply a target" in CIFix Firebase "Error: Must supply a target" in CI - firebase.json uses multiple hosting targets but none was a…
Firebase "Functions did not deploy properly" in CIFix Firebase "Error: Functions did not deploy properly" in CI - one or more functions failed to build, provis…