Skip to content
Latchkey

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-site

Common 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

  1. Run the build step so the output directory exists.
  2. Confirm the directory name matches hosting.public in firebase.json.
  3. Then run the hosting deploy.
Terminal
npm ci
npm run build
firebase deploy --only hosting --project my-project

Align 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.public in sync with the framework output directory.
  • Fail the job if the output directory is empty before deploying.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →