Skip to content

NextJS - If package.json has build: next build firebase deploy will fail #75

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

Open
atco-jh opened this issue Apr 27, 2023 · 1 comment
Open

Comments

@atco-jh
Copy link

atco-jh commented Apr 27, 2023

The package.json cannot have the build: next build script or firebase function will fail to deploy. This is very reproducible and happens every time.

example package.json

    "scripts": {
        "dev": "next dev",
        "build": "next build"
    }

I've encountered this error when it's the final stages when the function is building.

Error: Could not find 'pages' directory , which is very vague and confusing, but after figuring out a lot of issues , I am perplexed why this is an issue.

I am using src/pages folder structure in NextJS.

firebase.json

{
    "hosting": {
        "source": ".",
        "cleanUrls": true,
        "ignore": ["firebase.json", "**/.*", "**/node_modules/**", "functions/"],
        "rewrites": [
            {
                "source": "**",
                "function": "ssrNextFunc"
            },
            {
                "source": "**/**",
                "function": "ssrNextFunc"
            }
        ],
        "headers": [
            {
                "source": "**",
                "headers": [
                    {
                        "key": "Strict-Transport-Security",
                        "value": "max-age=63072000; includeSubDomains; preload"
                    }
                ]
            }
        ]
    }
}

There seems to be a mismatch somewhere as if you try to override this with anything else eg. build: next build src/ it will say this command will be ignored and firebase will use it's default and deploy will work.

BUT if it's build: next build, this doesn't get ignored, so I assume this means it must be matching firebase's build script, but the frustrating thing is that this will fail the deploy, and I do not know why for the life of me.

@atco-jh atco-jh changed the title NextJS - If package.json build: next build firebase deploy will fail NextJS - If package.json has build: next build firebase deploy will fail Apr 27, 2023
@gyak-efisco
Copy link

suddenly having the same issue on project that was perfectly deployable a couple of days ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants