Failed production build
Answered
Juniper Titmouse posted this in #help-forum
Juniper TitmouseOP
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
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
Build work on local with next build and start
On vercel, it fail, I have no idea why..
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 occurredError: 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.
10 Replies
Try redeploying without cache on Vercel.
What’s your app/[locale]/dashboard/page.js file?
What’s your app/[locale]/dashboard/page.js file?
Juniper TitmouseOP
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>
</>
)
}
Say you just cloned the repository to a blank machine. Other than npm install, do you need to run any other commands for it to work?
Juniper TitmouseOP
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..
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.
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.
Juniper TitmouseOP
I'll inspect this step by step no worry but thanks for your help !
Miniature Pinscher
What is your Node version?
Juniper TitmouseOP
20.11.0
Miniature Pinscher
Try setting the same (20) on Vercel in the general settings.
Answer
Juniper TitmouseOP
Just finished deployement, it was the node vesion that failed the build. Thanks mate !