-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Error occurred prerendering page "/_not-found" with pageExtensions option #65447
Comments
I have suddenly the same error. There were no changes made and this error happens when deploying the application.
|
I went spelunking in the code, and this looks suspicious to me: next.js/packages/next/src/server/app-render/app-render.tsx Lines 693 to 694 in c1f8d93
This non-null assertion means next.js/packages/next/src/server/app-render/app-render.tsx Lines 944 to 951 in c1f8d93
My guess is that this issue was introduced here: #64313 But I definitely don't have enough knowledge or context to confirm that or offer a suggestion on how to fix this |
Another thing I found — after running a build, looking at the # notice that a file shows up for every page entry
# but is missing for the not-found page
find .next/ -path '*client-reference-manifest.js' I'm guessing that this missing file corresponds to an undefined When I downgrade to v14.1.4, I see a couple of differences:
I now think this bug was caused by #62679 |
Maybe this next.js/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts Lines 349 to 352 in c1f8d93
|
Here's a minimal reproduction https://github.com/awmottaz/next-typeerror-not-found |
I have the same issue, builds fine locally but on Vercel I get this error:
|
Since today the build suddenly succeeds... must've been something related to Vercel? |
Not Vercel. I'm struggling with local builds and our AWS server is spitting out the same error too |
Downgraded to 14.1.4 from my package.json, and I can confirm I no longer see the following error:
|
experiencing same issue after upgrade to 15-rc |
What version is working for you? |
I think my problem was that I was having page.tsx inside an |
thank you for the quick reply. I don't have my index page inside a folder. But again would help to know what version you're using of 14 or if it's a canary of 15? |
I'm using latest 14 |
I get a similar error... I should also mention that im using next-intl Generating static pages (0/7) [ ]Error Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error ✓ Generating static pages (7/7)
|
@riccardolardi So 14.2.4 and are you using page extensions like OP? |
Yes, but no page extensions |
I am facing the same not found pre-render page issue while deploying in vercel in next js version 14.2.4. Any solutions? |
I don't have a notfounD page yet I get the error; Export encountered errors on following paths: |
@ericpark11 - Did you ever find a solution to this? I just installed next-intl into a new project and am facing the same issue. Thanks. |
This comment has been minimized.
This comment has been minimized.
@donbellamy I have fixed the issue but i was well into the project so I really had to make a new copy folder and really get down to the issue which was a pain. I think it was a minor async and use client issue. If you have just started i would just recommend following the next-intl document or watch a youtube video to get it going |
@ericpark11 did you fix the issue on next.js itself or next-intl project? |
for me it was nextjs itself iirc @petrosmm |
any chance you'll PR your fix into the nextjs code to fix this issue? -- I am assuming it is related to the not-found page and the use of pageExtensions @ericpark11 |
From my research, it seems that the only workaround is to use “not-found.ts” or "not-found.tsx". Briefly, the workaround is to use the file
/** @type {import("next").NextConfig} */
const nextConfig = {
reactStrictMode: true,
pageExtensions: [
"page.tsx",
"page.ts",
// FIXME: Next.js has a bug which does not resolve not-found.page.tsx correctly
// Instead, use `not-found.ts` as a workaround
// "ts" is required to resolve `not-found.ts`
// https://github.com/vercel/next.js/issues/65447
"ts"
],
};
module.exports = nextConfig; 📝 Probably, You can also work around this by using Example:
This example is based on @riccardolardi reproduce repo
However, I believe this behavior is a bug because it is inconsistent. I expect it to be corrected for this reason. Footnotes
|
I also had this issue and i think i managed to fix it this morning. I'm using next-intl as well (like few other people here) and fix for me was turning not-found.tsx page into server component and adding "force-dynamic" on top: export const dynamic = "force-dynamic";
import { redirect } from "next/navigation";
export default function NotFound() {
redirect("/dashboard");
return <div></div>;
} I also added My next.config.mjs file looks like this: import createNextIntlPlugin from "next-intl/plugin";
const withNextIntl = createNextIntlPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
reactStrictMode: true,
};
export default withNextIntl(nextConfig); |
Thank you so much !!
"next": "^14.2.7", |
I had the same problem and in my case it was useSearchParams(); declared in a useContext. I managed to keep version 15rc by removing it from the context. |
The issue is not with the not-found default page itself. The error is a bit confusing though. If you click the first line in the error it would take you to the piece of code. In my case it was the Quill import from 2.0.2 which was leading to it. the exact code was document.addEventListner where document was unavailable. Somehow making the component where it was being imported as 'use client' was not solving the issue. Changing to lazy loading the library fixed the issue though. |
I thought this had solved my building issue, as in the fact the build finishes successfully. If I remove that Did anyone actually overcome this issue? |
Export encountered errors on following paths: |
Spent hours trying to figure out, this helped me resolve the issue! |
thank u, this worked |
Adding force-dynamic to the page.tsx files solved the problem export const dynamic = 'force-dynamic'; @mk0y Thank you so much for pointing that out! |
Chipping in here Adding Pretty annoying that there is no better fix. Pretty hit or miss – I didn't have to add this force-dynamic to all the pages |
guys i spent an hour on this bug my issue was that i didn't have my ENVs set up in vercel leaving this here in case it helps someone |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/misty-glade-yh92cc
To Reproduce
After update to 14.2.* version, when i use
pageExtensions
innext.config
, i got an error while try to build my appi have in my
app
folder all files with.page.tsx
-Current vs. Expected behavior
Build app fail with
pageExtentions
optionProvide environment information
Operating System: Platform: linux Arch: x64 Version: #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 4 14:39:20 UTC 2 Available memory (MB): 15622 Available CPU cores: 12 Binaries: Node: 20.12.2 npm: 10.5.0 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 14.2.3 // Latest available version is detected (14.2.3). eslint-config-next: 14.2.3 react: 18.2.0 react-dom: 18.2.0 typescript: 5.4.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: