Description
Link to the code that reproduces this issue
https://github.com/NasserBvB/generate-static-params-issue
To Reproduce
While building a Next.js application with output: "export"
in next.config.js
, I encountered an error regarding the missing generateStaticParams()
function, despite it being implemented and returning an empty list. This error specifically affects dynamic pages in the project.
Notably, the build succeeds as expected when generateStaticParams()
returns at least one article parameter in the list. The issue only arises when it returns an empty list ([]
).
Steps to Reproduce
- Create a new Next.js application using
[email protected]
. - Add a dynamic page at
articles/[article]/page.js
. - Implement
generateStaticParams
inarticles/[article]/page.js
and set it to return an empty list ([]
). - Configure
output: "export"
innext.config.js
. - Run the build command.
Expected Behavior
The build should succeed without any issues, recognizing that generateStaticParams()
is implemented and returning an empty list of article slugs.
Actual Behavior
An error occurs during the build, specifically stating:
Error: Page "/articles/[article]" is missing "generateStaticParams()" so it cannot be used with "output: export" config.
However, when generateStaticParams()
returns a list with at least one article slug, the build completes successfully as expected.
Additional Context
- I’ve confirmed that
generateStaticParams()
exists inarticles/[article]/page.js
, and the issue persists only when it returns an empty list.
Current vs. Expected behavior
Expected Behavior
The build should succeed without any issues, recognizing that generateStaticParams()
is implemented and returning an empty list of article slugs.
Actual Behavior
An error occurs during the build, specifically stating:
Error: Page "/articles/[article]" is missing "generateStaticParams()" so it cannot be used with "output: export" config.
However, when generateStaticParams()
returns a list with at least one article slug, the build completes successfully as expected.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 18.19.0
npm: 10.2.3
Yarn: 1.22.22
pnpm: 9.12.0
Relevant Packages:
next: 14.2.8 // An outdated version detected (latest is 15.0.1), upgrade is highly recommended!
eslint-config-next: 14.2.8
react: 18.3.1
react-dom: 18.3.1
typescript: 5.5.4
Next.js Config:
output: export
Which area(s) are affected? (Select all that apply)
create-next-app, Output (export/standalone), Script (next/script)
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response