App Hosting Deployment Error

I tried linking my nextjs website (https://github.com/synodicai/synodic, the /website folder) to App Hosting on Firebase, but I am getting the following error:

2024-05-15 14:49:43.978 EDT
Finished Step #2
2024-05-15 14:49:43.978 EDT
ERROR
2024-05-15 14:49:43.978 EDT
ERROR: build step 2 "gcr.io/k8s-skaffold/pack" failed: step exited with non-zero status: 1

0 3 210
3 REPLIES 3

I have the same problem. I was just following the steps at the Firebase Doc's get started section (https://firebase.google.com/docs/app-hosting/get-started) and made the boilerplate app with `npm init @apphosting`, pushed it to a git repo, then followed the web console prompts to setup the github integration and name a backend, and it magically started deploying. Then it failed on Step #2 with the same messages you got. Scrolling up in the logs, I see that it did not find a nextjs config but I'm not sure if that's the source of the problem.

cooking_0-1715909521022.png

I wonder if it's because the project is in typescript? Is it not compiling it to js first?

https://firebase.google.com/docs/app-hosting/about-app-hosting#known-issues

You can see in the known issues it's because it's not the root folder. 
  • Projects with nested package.json files are currently not supported, regardless of whether root\_directory is configured with the Firebase console or the CLI. A fix will be available in a later release.

As a "hacky" temporal solution meanwhile, I made it work by:
1. Duplicate package.json in the repo's root directory
2. Update the scripts on the new root's package.json from:

"build": "next build"

to:

"build": "cd <nested directory> && npm run build"