vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.93k stars 26.68k forks source link

`app/icon.tsx` and `npm run dev` with `output: "export"` #68874

Open abernier opened 1 month ago

abernier commented 1 month ago

Link to the code that reproduces this issue

https://github.com/abernier/bug-next-icontsx.git

To Reproduce

$ git clone https://github.com/abernier/bug-next-icontsx.git
$ cd bug-next-icontsx
$ npm ci
$ npm run dev

Current vs. Expected behavior

$ npm run dev

> myapp95@0.1.0 dev
> next dev

  ▲ Next.js 14.2.5
  - Local:        http://localhost:3000

 ✓ Starting...
 ✓ Ready in 1274ms
 ○ Compiling / ...
 ✓ Compiled / in 1538ms (537 modules)
 GET / 200 in 1703ms
 ✓ Compiled in 114ms (250 modules)
 ✓ Compiled /icon in 76ms (311 modules)
 ⨯ Error: Page "/icon/[[...__metadata_id__]]/route" is missing exported function "generateStaticParams()", which is required with "output: export" config.
    at DevServer.renderToResponseWithComponentsImpl (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/base-server.js:1082:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DevServer.renderPageComponent (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/base-server.js:1931:24)
    at async DevServer.renderToResponseImpl (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/base-server.js:1969:32)
    at async DevServer.pipeImpl (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/base-server.js:920:25)
    at async NextNodeServer.handleCatchallRenderRequest (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/next-server.js:272:17)
    at async DevServer.handleRequestImpl (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/base-server.js:816:17)
    at async /Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/dev/next-dev-server.js:339:20
    at async Span.traceAsyncFn (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/trace/trace.js:154:20)
    at async DevServer.handleRequest (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/dev/next-dev-server.js:336:24)
    at async invokeRender (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/lib/router-server.js:174:21)
    at async handleRequest (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/lib/router-server.js:353:24)
    at async requestHandlerImpl (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/lib/router-server.js:377:13)
    at async Server.requestListener (/Users/abernier/tmp/bug-next-icontsx/node_modules/next/dist/server/lib/start-server.js:141:13) {
  page: '/icon'
}
 ✓ Compiled /_error in 449ms (770 modules)
 GET /icon?3f809f6ad65182c2 500 in 850ms

build is ok though:

$ npm run build

> myapp95@0.1.0 build
> next build

  ▲ Next.js 14.2.5

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
 ✓ Generating static pages (5/5)
 ✓ Collecting build traces
 ✓ Finalizing page optimization

Route (app)                              Size     First Load JS
┌ ○ /                                    5.25 kB        92.4 kB
├ ○ /_not-found                          871 B            88 kB
└ ○ /icon                                0 B                0 B
+ First Load JS shared by all            87.1 kB
  ├ chunks/23-bc0704c1190bca24.js        31.6 kB
  ├ chunks/fd9d1056-2821b0f0cabcd8bd.js  53.6 kB
  └ other shared chunks (total)          1.86 kB

○  (Static)  prerendered as static content

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Sat Jul 13 00:57:28 PDT 2024; root:xnu-11215.0.165.0.4~50/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 20.11.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 8.3.1
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: 14.2.5
  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)

Not sure, Metadata, Output (export/standalone)

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

next dev (local)

Additional context

No response

abernier commented 1 month ago

https://www.linkedin.com/feed/update/urn:li:ugcPost:7222279285246509056?commentUrn=urn%3Ali%3Acomment%3A%28ugcPost%3A7222279285246509056%2C7229372146714656769%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287229372146714656769%2Curn%3Ali%3AugcPost%3A7222279285246509056%29

samcx commented 1 month ago

@abernier Thank you for submitting an issue!

Can you try this on the latest canary? I'm actually getting a different error :thinkies:

 ⨯ Error: export const dynamic = "force-static"/export const revalidate not configured on route "/icon" with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html-export

Since you're using output: export, you need to make sure this Route Handler is using static instead.