Skip to content
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

Static output build crash in catch-all route, got error [...all]" is missing "generateStaticParams()" so it cannot be used with "output: export" config. #62224

Open
Innei opened this issue Feb 19, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@Innei
Copy link

Innei commented Feb 19, 2024

Link to the code that reproduces this issue

https://github.com/Innei/nextjs-catch-all-static-output-reproduction

To Reproduce

The code:

// [...all]/page.tsx


export async function generateStaticParams() {
  const jsonData = JSON.parse(
    readFileSync(resolve(process.cwd(), 'markdown/index.json'), {
      encoding: 'utf-8',
    }),
  )

  const sectionsText = [] as string[]

  const sections = [] as {
    path: string

    text: string
  }[]

  for (const path of jsonData) {
    const file = readFileSync(resolve(process.cwd(), 'markdown', path), {
      encoding: 'utf-8',
    })

    // sectionsText.push(file)
    sections.push({
      path: path.replace('.md', '').replace('./sections/', ''),
      text: file,
    })
  }

  console.log(sections, 'sections-page') // The value is not empty array with object.
// [ { path: '1.about', text: '# About' } ] ⬆️

  return sections
}

export default (props: any) => {
  return <pre>{JSON.stringify(props, null, 2)}</pre>
}

  1. run build

log:


   ▲ Next.js 14.1.0

   Creating an optimized production build ...
 ✓ Compiled successfully
   Linting and checking validity of types  . ⨯ ESLint must be installed in order to run during builds: pnpm install --save-dev eslint
 ✓ Linting and checking validity of types    
   Collecting page data  .[ { path: '1.about', text: '# About' } ] sections-page // See this

> Build error occurred
Error: Page "/reading/[...all]" is missing "generateStaticParams()" so it cannot be used with "output: export" config.
    at /Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/index.js:1102:59
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Span.traceAsyncFn (/Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/trace/trace.js:151:20)
    at async Promise.all (index 6)
    at async /Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/index.js:981:17
    at async Span.traceAsyncFn (/Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/trace/trace.js:151:20)
    at async /Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/index.js:918:124
    at async Span.traceAsyncFn (/Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/trace/trace.js:151:20)
    at async build (/Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/index.js:374:9)
    at async main (/Users/innei/git/reproduction/nextjs-catch-all-static-output-reproduction/node_modules/.pnpm/next@14.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/bin/next:155:5)
   Collecting page data  . ELIFECYCLE  Command failed with exit code 1.

Current vs. Expected behavior

current: Build crash

Expected: Should static output

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:00 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6020
Binaries:
  Node: 20.8.1
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: 8.14.1
Relevant Packages:
  next: 14.1.0
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: export

Which area(s) are affected? (Select all that apply)

App Router

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

I found some related issues, but they're not the same

#61213 #58171

NEXT-2767

@Innei Innei added the bug Issue was opened via the bug report template. label Feb 19, 2024
@Innei
Copy link
Author

Innei commented Mar 11, 2024

This is an incorrect error message and is very confusing. While the above may be wrong about the return value of this function, it should be this reported error

@huozhi huozhi added the linear: next Confirmed issue that is tracked by the Next.js team. label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

No branches or pull requests

2 participants