Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase app hosting NextJs build fails when NODE_ENV is set to production in apphosting.yaml file #414

Closed
ashishmahla opened this issue May 19, 2024 · 2 comments
Assignees
Labels
firebase app hosting Firebase App Hosting builder kind/bug Something isn't working

Comments

@ashishmahla
Copy link

Describe the bug
Deployment of NextJs app on firebase app hosting fails when NODE_ENV is set to production in the apphosting.yaml file and availability is set to BUILD as follows:

  - variable: NODE_ENV
    value: "production"

When setting NODE_ENV availability to RUNTIME, it builds successfully:

  - variable: NODE_ENV
    value: "production"
    availability:
      - RUNTIME

Additional context
How are you using GCP buildpacks?
I am using Firebase app hosting, so cloud build I think.

What language is your project primarily written in?
Node.js

Steps To Reproduce
Set NODE_ENV=production in apphosting.yaml file as follows:

  - variable: NODE_ENV
    value: "production"

Error Logs

Step #2: Module not found: Can't resolve '@/app/components/link'
Step #2:
Step #2: https://nextjs.org/docs/messages/module-not-found
Step #2:
Step #2:
Step #2: > Build failed because of webpack errors
Step #2: node:internal/modules/run_main:115
Step #2: triggerUncaughtException(
Step #2: ^
Step #2:
Step #2: [Error: ENOENT: no such file or directory, lstat '/workspace/.next/standalone'] {
Step #2: errno: -2,
Step #2: code: 'ENOENT',
Step #2: syscall: 'lstat',
Step #2: path: '/workspace/.next/standalone'
Step #2: }
Step #2:
Step #2: Node.js v22.2.0
Step #2: --------------------------------------------------------------------------------
Step #2: Sorry your project couldn't be built.
Step #2: Our documentation explains ways to configure Buildpacks to better recognise your project:
Step #2: -> https://cloud.google.com/docs/buildpacks/overview
Step #2: If you think you've found an issue, please report it:
Step #2: -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
Step #2: --------------------------------------------------------------------------------

I am unsure whether this is expected behaviour or not. I would like to apologise in advance, I don't primarily work with Node.js or Webpack.

@ashishmahla ashishmahla added the kind/bug Something isn't working label May 19, 2024
@kennethye1 kennethye1 added the firebase app hosting Firebase App Hosting builder label May 21, 2024
@abhis3
Copy link
Collaborator

abhis3 commented May 22, 2024

Hi there, would it be possible to share the code you're deploying? It would be great to take a look at your use case and debug it further if possible, thanks!

@abhis3
Copy link
Collaborator

abhis3 commented Jun 12, 2024

I think the issues here have been ironed out, I was able to successfully deploy my sample app with a NODE_ENV value set to both production and development, see https://github.com/abhis3/express-on-firebase/blob/856e645d040ebd31d52062e3aca9a5140e620be8/apphosting.yaml#L12-L13

Closing out, please feel free to reopen if there are any other issues thanks!

@abhis3 abhis3 closed this as completed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
firebase app hosting Firebase App Hosting builder kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants