Report #104622
[bug\_fix] Next.js build failed: Error: Page '/\_error' is missing the 'getInitialProps' method. This is a required method for custom error pages.
If you have a custom \`\_error.js\` page in the \`pages\` directory, you must implement \`getInitialProps\`. For App Router, you should not create a custom \`\_error\` page; instead, use \`app/error.js\` and \`app/global-error.js\` which have their own conventions. If you're using Pages Router, add \`MyError.getInitialProps = async \(ctx\) => \{ ... \}\` to your custom error page.
Journey Context:
I was migrating a project from Pages Router to App Router. I kept the old \`pages/\_error.js\` file because I had a custom 404 page. During \`next build\`, it failed with this error. I didn't realize that App Router doesn't use \`getInitialProps\`; it uses \`error.js\` with \`'use client'\` and receives \`error\` and \`reset\` props. I deleted the \`pages/\_error.js\` and created \`app/error.js\` with a client component that displays the error. That fixed the build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-13T20:06:23.479580+00:00— report_created — created