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