App Hosting: customizing build commands and/or deploying functions

425 views
Skip to first unread message

Alan deLespinasse

unread,
Mar 12, 2025, 7:34:27 PMMar 12
to Firebase Google Group
I'm trying to run a Next.js app on Firebase App Hosting, and running into some errors on deploy.

The first error came from the npm command that it uses to install Node dependencies. The command it uses is shown in the logs as:

Running "npm ci --quiet --no-fund --no-audit (NODE_ENV=development)"

(I assume (NODE_ENV=development) is not part of the actual command line)

In my app I thought I needed to add a flag to that command, but I found a workaround (setting an option in the .npmrc).

But I haven't found a good solution to the next error I encountered. This came from the fact that it doesn't automatically build and deploy Firebase Functions. I would have thought this would just work, since it's Firebase, but it doesn't seem to even try. When it runs "npm run build" to build the Next.js app, that does Typescript checking, which fails in the functions directory because that has separate dependencies in its own package.json that need to be installed.

This person on Stack Overflow had the same problem and never got an answer; their workaround is to set up tsconfig.json to ignore the functions directory and do a separate, manual deploy of the functions. 

The best thing would be for App Hosting to automatically do the right thing when there is a functions directory.

The second best thing would be to let the developer modify the commands used in the build process. In fact I suspect there might be a way, but it seems to be undocumented.  This seems like an important feature whether or not it turns out to be necessary for my use case.

(Gemini told me I could add a build.commands section in apphosting.yaml, but it didn't work; I guess it was hallucinating.)

So am I missing something that would let me customize the commands?

Alan deLespinasse

unread,
Mar 12, 2025, 7:41:52 PMMar 12
to Firebase Google Group
I guess maybe this feature request is for customizing the build commands:


I'll add a feature request for automatic support of functions.

Ebrahim Khalil

unread,
Mar 15, 2025, 1:51:22 PMMar 15
to Firebase Google Group
لنبني حياتنا وننموا ونتطور
مع جوجل 

Alex Grissom

unread,
Mar 15, 2025, 1:52:25 PMMar 15
to Firebase Google Group
I left an email yesterday but I didnt see it here after sending, not sure how these groups work yet. That being said, im sorry if this is repeated.

I found that hosting a NextJS app on Firebase doesnt work very easily because its not setup for NextJs. You would have to make several changes to the workflow and upload process. I never got it to work.

I started using Vercel, which is who made and maintains NextJs. Their platform is set up for using it without major issues. I use GitHub and every time I commit a change it runs the build and goes live. Branches are automatically set up in a "practice" environment that is live but gives a separate url so you can test in private. 

Alan deLespinasse

unread,
Mar 16, 2025, 5:11:05 PMMar 16
to Firebase Google Group
I think you're probably talking about trying to run Next.js apps on Firebase Hosting. I'm using the newer Firebase App Hosting [beta], which specifically supports Next.js. 
Reply all
Reply to author
Forward
0 new messages