Next.js Discord

Discord Forum

Failed production build

Answered
Couch's Kingbird posted this in #help-forum
Open in Discord
Couch's KingbirdOP
ReferenceError: File is not defined
at 70665 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:88290)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:128)
at 74990 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:32133)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:128)
at 80995 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:1159)
at t (/vercel/path0/.next/server/webpack-runtime.js:1:128)
at t (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93922)
at /vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93980
at t.X (/vercel/path0/.next/server/webpack-runtime.js:1:1206)
at /vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93935
Build error occurred
Error: Failed to collect page data for /[locale]/dashboard
at /vercel/path0/node_modules/next/dist/build/utils.js:1268:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}
Error: Command "npm run build" exited with 1

const dynamic = "force-dynamic"
export {dynamic}


export default async function DashboardLayout({ children, params }: { children: React.ReactNode, params: {locale: Locale}}) {

    await ensureUserIsLoggedIn()
    const tr = await getTranslations(params.locale) 
    
    const dashboardMenu = [
        {to: '/dashboard', title: tr("dashboard.menu.profile")},
        {to: '/dashboard/orders', title: tr("dashboard.menu.order")},
    ]

    return (
        <LayoutTemplate>
              <>
                <SideMenu menuItems={dashboardMenu} locale={params.locale} />
                <section style={{display: "flex",flexDirection: "column",padding: "2rem",backgroundColor: "#C6DCE4", borderRadius: "0 8px 8px 0"}}>
                    {children}
                </section>
            </>
        </LayoutTemplate>
    )
}


Build work on local with next build and start
On vercel, it fail, I have no idea why..
Answered by Miniature Pinscher
Try setting the same (20) on Vercel in the general settings.
View full answer

10 Replies

@Couch's Kingbird ReferenceError: File is not defined at 70665 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:88290) at t (/vercel/path0/.next/server/webpack-runtime.js:1:128) at 74990 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:32133) at t (/vercel/path0/.next/server/webpack-runtime.js:1:128) at 80995 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:1159) at t (/vercel/path0/.next/server/webpack-runtime.js:1:128) at t (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93922) at /vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93980 at t.X (/vercel/path0/.next/server/webpack-runtime.js:1:1206) at /vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93935 > Build error occurred Error: Failed to collect page data for /[locale]/dashboard at /vercel/path0/node_modules/next/dist/build/utils.js:1268:15 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { type: 'Error' } Error: Command "npm run build" exited with 1 const dynamic = "force-dynamic" export {dynamic} export default async function DashboardLayout({ children, params }: { children: React.ReactNode, params: {locale: Locale}}) { await ensureUserIsLoggedIn() const tr = await getTranslations(params.locale) const dashboardMenu = [ {to: '/dashboard', title: tr("dashboard.menu.profile")}, {to: '/dashboard/orders', title: tr("dashboard.menu.order")}, ] return ( <LayoutTemplate> <> <SideMenu menuItems={dashboardMenu} locale={params.locale} /> <section style={{display: "flex",flexDirection: "column",padding: "2rem",backgroundColor: "#C6DCE4", borderRadius: "0 8px 8px 0"}}> {children} </section> </> </LayoutTemplate> ) } Build work on local with next build and start On vercel, it fail, I have no idea why..
Try redeploying without cache on Vercel.

What’s your app/[locale]/dashboard/page.js file?
Couch's KingbirdOP
export default async function AccountPage ({params}: {params: {locale: Locale}}) {
    
    await ensureUserIsLoggedIn()
    const data = await getAccount()
    if (!data) return <h1>User data not found</h1>
    const tr = await getTranslations(params.locale)


    return (
        <>

            <div>

                <h1>{tr("dashboard.account.profile.title")}</h1>
                <UpdateAccountForm 
                    email={data.email}
                    emailVerifiedAt={data.emailVerifiedAt}
                    image={data.image}
                    name={data.name}
                    phoneNumber={data.phoneNumber}
                    phonePrefix={data.phonePrefix}
                    phoneVerifiedAt={data.phoneVerifiedAt}
                    createdAt={data.createdAt}
                />

                <h1>Mot de passe</h1>
                <UpdateAccountPasswordForm/>

                <h1>Preferences</h1>
                <UpdateAccountPreferences followNewsletter={data.followNewsletter} />

                <DeleteAccountBtn>
                    {tr("dashboard.account.profile.deleteBtn")}
                </DeleteAccountBtn>

            </div>

        </>
    )   
}
Couch's KingbirdOP
I updated a live project with all changes. I updated the database with prisma migrate / reset/ seed. Checked on prisma studio, data are well seeded no problem there.
I purged everything and still got the issue.
I guess I'm donna remove all dashboard and see if build works..
Sorry, not too sure then since I don’t use this i18n library.

What happens on Vercel is essentially they clone your repo to a blank machine, set up the environment variables there if provided, they run npm install then npm run build and that’s it. So if it doesn’t work, likely there is another command you need to run to fully set up the repo.
Couch's KingbirdOP
I'll inspect this step by step no worry but thanks for your help !
@Couch's Kingbird ReferenceError: File is not defined at 70665 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:88290) at t (/vercel/path0/.next/server/webpack-runtime.js:1:128) at 74990 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:32133) at t (/vercel/path0/.next/server/webpack-runtime.js:1:128) at 80995 (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:1159) at t (/vercel/path0/.next/server/webpack-runtime.js:1:128) at t (/vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93922) at /vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93980 at t.X (/vercel/path0/.next/server/webpack-runtime.js:1:1206) at /vercel/path0/.next/server/app/[locale]/dashboard/page.js:1:93935 > Build error occurred Error: Failed to collect page data for /[locale]/dashboard at /vercel/path0/node_modules/next/dist/build/utils.js:1268:15 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { type: 'Error' } Error: Command "npm run build" exited with 1 const dynamic = "force-dynamic" export {dynamic} export default async function DashboardLayout({ children, params }: { children: React.ReactNode, params: {locale: Locale}}) { await ensureUserIsLoggedIn() const tr = await getTranslations(params.locale) const dashboardMenu = [ {to: '/dashboard', title: tr("dashboard.menu.profile")}, {to: '/dashboard/orders', title: tr("dashboard.menu.order")}, ] return ( <LayoutTemplate> <> <SideMenu menuItems={dashboardMenu} locale={params.locale} /> <section style={{display: "flex",flexDirection: "column",padding: "2rem",backgroundColor: "#C6DCE4", borderRadius: "0 8px 8px 0"}}> {children} </section> </> </LayoutTemplate> ) } Build work on local with next build and start On vercel, it fail, I have no idea why..
Miniature Pinscher
What is your Node version?
Couch's KingbirdOP
20.11.0
@Couch's Kingbird 20.11.0
Miniature Pinscher
Try setting the same (20) on Vercel in the general settings.
Answer
Couch's KingbirdOP
Just finished deployement, it was the node vesion that failed the build. Thanks mate !