Skip to content

Angular deploy with custom commands #351

Closed

Description

@renanrider

I'm trying to deploy an Angular project on Firebase App Hosting, using custom build commands for both production and development environments.

I created two configuration files:

apphosting.production.yaml

apphosting.development.yaml

Each file is associated with a backend configured for its respective environment (production or development).

apphosting.development.yaml

scripts:
  buildCommand: npm install && ng build --configuration development

apphosting.production.yaml

scripts:
  buildCommand: npm install && ng build --configuration production

The build seems to work, but after deploying, when I access the app, I get this error on the page:

Service Unavailable
or Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.

Has anyone experienced something similar or knows what might be causing this?

The only relevant documentation I found is here:
👉 https://firebase.google.com/docs/app-hosting/configure?hl=pt-br#override-scripts

Any help would be appreciated!

Activity

  1. leoortizz commented on Oct 27, 2026

    @leoortizz
    Member

    Thanks for the report, and sorry for the slow reply.

    scripts.buildCommand replaces App Hosting's Angular build, so the Angular adapter never runs and App Hosting doesn't get a start command for your app. Apps without SSR then fall back to npm start (ng serve), and the Angular CLI isn't installed at runtime, so the new revision never starts (ng: not found in the Cloud Run logs).

    To build a different configuration per environment and keep the adapter, remove scripts.buildCommand and pass the configuration as a build-time variable instead:

    package.json

    "build": "ng build --configuration $APP_ENV"

    apphosting.development.yaml

    env:
      - variable: APP_ENV
        value: development
        availability:
          - BUILD

    apphosting.production.yaml

    env:
      - variable: APP_ENV
        value: production
        availability:
          - BUILD

    When APP_ENV isn't set, for example in a local npm run build, ng build uses your defaultConfiguration. Use $APP_ENV rather than ${APP_ENV:-production}: the current adapter fails on the braces, and #697 fixes that.

    Closing this for now. If you still see the error with this setup, please comment with your Cloud Build log and we'll reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions