Error occurred prerendering page
Unanswered
Dani posted this in #help-forum
DaniOP
Hello, I am facing error while building my nextjs application, it's failing to export my pages. Please somebody help. Thank you!
66 Replies
Can you provide more details on the error you’re getting? Maybe the error logs. We are unable to help without context.
@Dani Any updates?
@LuisLl <@1244979225924993094> Any updates?
DaniOP
TypeError: (intermediate value).default is not a function
at c.metadata.icon (D:\Web Development\Upvave\next-website\mynextwebsite.next\server\app\about\page.js:1:1740)
at async D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:227676
at async Promise.all (index 1)
at async tw (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:227744)
at async Promise.all (index 0)
at async tk (D:\Web Development\Upvave\next-website\mynextwebsite\nodemodules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:227861)
at async t (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:228214)
at async tx (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:228741)
at async tj (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:13:2320)
at async D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:13:3028 {
digest: '2713151883'
}
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
digest: '2713151883'
}
Error occurred prerendering page "/about". Read more: https://nextjs.org/docs/messages/prerender-error
at c.metadata.icon (D:\Web Development\Upvave\next-website\mynextwebsite.next\server\app\about\page.js:1:1740)
at async D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:227676
at async Promise.all (index 1)
at async tw (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:227744)
at async Promise.all (index 0)
at async tk (D:\Web Development\Upvave\next-website\mynextwebsite\nodemodules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:227861)
at async t (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:228214)
at async tx (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:228741)
at async tj (D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:13:2320)
at async D:\Web Development\Upvave\next-website\mynextwebsite\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:13:3028 {
digest: '2713151883'
}
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
digest: '2713151883'
}
Error occurred prerendering page "/about". Read more: https://nextjs.org/docs/messages/prerender-error
Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
Generating static pages (12/14) [ ===]Time 11.0948
Time 10.4506
✓ Generating static pages (14/14)
/blog/page: /blog
/contact/page: /contact
/page: /
/portfolio/page: /portfolio
/services/page: /services
Generating static pages (12/14) [ ===]Time 11.0948
Time 10.4506
✓ Generating static pages (14/14)
Export encountered errors on following paths:/about/page: /about
/blog/page: /blog
/contact/page: /contact
/page: /
/portfolio/page: /portfolio
/services/page: /services
I'm getting this error repeatedly several times in the console
Are you writing your page components as:
If page components are not the problem try deleting .next and node_modules folder and try again.
export default function/async function PageComponent(){}
If page components are not the problem try deleting .next and node_modules folder and try again.
And I tried deleting .next and package-lock.json file
DaniOP
And now I tried deleting node modules and .next
But still same error
DaniOP
@LuisLl my project was running on an older version of Nextjs, I upgraded it to the latest version, the previous error is gone but there is a new error now, can u help me with it?
Type error: Type '{ params: { slug: string; }; }' does not satisfy the constraint 'PageProps'.
Types of property 'params' are incompatible.
Type '{ slug: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
32 |
33 | // Check the prop type of the entry function
35 |
36 | // Check the arguments and return type of the generateMetadata function
37 | if ('generateMetadata' in entry) {
Next.js build worker exited with code: 1 and signal: null
Types of property 'params' are incompatible.
Type '{ slug: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
32 |
33 | // Check the prop type of the entry function
34 | checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()| ^
35 |
36 | // Check the arguments and return type of the generateMetadata function
37 | if ('generateMetadata' in entry) {
Next.js build worker exited with code: 1 and signal: null
this is my slug page
@LuisLl
Yes, just do this:
And where you're reading the params now await it:
Page ({ params } : { params: Promise<{ slug: string; }> }){
And where you're reading the params now await it:
const post = await getBlogPostBySlug((await params).slug);
@LuisLl Yes, just do this:
ts
Page ({ params } : { params: Promise<{ slug: string; }> }){
And where you're reading the params now await it:
ts
const post = await getBlogPostBySlug((await params).slug);
DaniOP
I did this and it worked:
export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
const {slug} = await params;
const post = await getBlogPostBySlug(slug);
export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
const {slug} = await params;
const post = await getBlogPostBySlug(slug);
but now I'm having pre render errors on different pages
like whenever I build the project it gives pre render error on a different page
@LuisLl
@Dani like whenever I build the project it gives pre render error on a different page
What is the error now? Can you show the logs?
@LuisLl What is the error now? Can you show the logs?
DaniOP
Error occurred prerendering page "/about". Read more: https://nextjs.org/docs/messages/prerender-error
Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
Export encountered an error on /about/page: /about, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null
Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
Export encountered an error on /about/page: /about, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null
this is in the error logs
DaniOP
should I share my project's github repo link?
@LuisLl
@Dani should I share my project's github repo link?
If you can, yes. The error doesn't give details tbh
do I need to share the backend asw?
DaniOP
@LuisLl
DaniOP
config.module.rules.push({
test: /.(png|jpg|gif|svg)$/i,
type: 'asset/resource',
generator: {
filename: 'static/media/[name].[hash][ext]',
},
});
test: /.(png|jpg|gif|svg)$/i,
type: 'asset/resource',
generator: {
filename: 'static/media/[name].[hash][ext]',
},
});
@LuisLl this piece of code in nextjs config file's webpack config is causing the pre render error
how do I fix it?
First of all where did you get that config from?
Do you a need it?
Do you a need it?
@LuisLl First of all where did you get that config from?
Do you a *need* it?
DaniOP
I was assigned this project and it was already there
The project seems to be working fine without it i guess
as much I checked it, it was running smoothly w/o it too
not sure whats the purpose of it
thats why I asked
Simply extends the webpack config to catch all files that are images (.png, jpg, etc) and serves them from a different location. Here they will be served from .next/static/media/… (the rest is just the file name + a hash + the file extension)
The about page is the only one getting that error?
@LuisLl The about page is the only one getting that error?
DaniOP
it was in different pages, different on every new build
@LuisLl Simply extends the webpack config to catch all files that are *images* (.png, jpg, etc) and serves them from a different location. Here they will be served from .next/static/media/… (the rest is just the file name + a hash + the file extension)
DaniOP
so it wont be much of a problem if I exclude it?
I can think of what might be causing the issue, but would be a lot of work just to test it :/
If only that piece of webpack config is the issue, then what could fix it is importing the images before you pass them to next <Image /> component, maybe since you’re changing where the resources are being pulled from (with that webpack rule) and you’re passing the
src
with the original url of the image@LuisLl If only that piece of webpack config is the issue, then what could fix it is importing the images before you pass them to next <Image /> component, maybe since you’re changing where the resources are being pulled from (with that webpack rule) and you’re passing the `src` with the original url of the image
DaniOP
doesnt that makes an issue importing files before using in nextjs?
Wdym? When you import an image?
@LuisLl Wdym? When you import an image?
DaniOP
like importing and using instead of using path
Can you build the app like this:
NODE_ENV=development next build
@LuisLl Can you build the app like this:
`NODE_ENV=development next build`
DaniOP
where should I add this?
@Dani where should I add this?
Just in the terminal.
What
What this command will do is running the build in development mode instead of production. You get more error traces like that.
What
npm run build
does is running next build
What this command will do is running the build in development mode instead of production. You get more error traces like that.
@LuisLl Just in the terminal.
What `npm run build` does is running `next build`
What this command will do is running the build in development mode instead of production. You get more error traces like that.
DaniOP
like just copy paste this line in the terminal ?NODE_ENV=development next build
Yes. It should start building your app
DaniOP
it isnt running
NODE_ENV=development : The term 'NODE_ENV=development' is not
recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ NODE_ENV=development next build
+~~~~
+ CategoryInfo : ObjectNotFound: (NODE_ENV=developme
nt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ NODE_ENV=development next build
+
+ CategoryInfo : ObjectNotFound: (NODE_ENV=developme
nt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
@LuisLl
that’s a power shell issue
$env:NODE_ENV = "development"
next build
@LuisLl that’s a power shell issue
$env:NODE_ENV = "development"
next build
DaniOP
I am running in vs code 's terminal
But you’re using powershell as the default terminal I assume. You can see when you create a new terminal
DaniOP
ohh yeaa that
@LuisLl But you’re using powershell as the default terminal I assume. You can see when you create a new terminal
DaniOP
which terminal should I use?
@LuisLl that’s a power shell issue
$env:NODE_ENV = "development"
next build
Did you try with these commands together?
Still fails?
Still fails?
in a different terminal asw
If you have git bash try that instead. Which one did you use?
@LuisLl If you have git bash try that instead. Which one did you use?
DaniOP
I tried using bash and command prompt asw