nextjs config_error ai_generated true

错误:无效的段配置导出。只允许 'dynamic', 'dynamicParams', 'revalidate', 'fetchCache', 'runtime', 'preferredRegion', 'maxDuration'。

Error: Invalid segment config export. Only 'dynamic', 'dynamicParams', 'revalidate', 'fetchCache', 'runtime', 'preferredRegion', 'maxDuration' are allowed.

ID: nextjs/invalid-segment-config-export

其他格式: JSON · Markdown 中文 · English
90%修复率
88%置信度
1证据数
2023-11-10首次发现

版本兼容性

版本状态引入弃用备注
Next.js 13.x active
Next.js 14.x active
Next.js 15.x active

根因分析

页面或布局导出了一个包含不受支持的键的配置对象(例如,将 'generateStaticParams' 作为配置键而不是函数,或拼写错误的配置名称)。

English

A page or layout exports a config object with an unsupported key (e.g., 'generateStaticParams' as a config key instead of a function, or a misspelled config name).

generic

官方文档

https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config

解决方案

  1. Check the exported config object for any keys not in the allowed list. Remove or correct them. Ensure generateStaticParams is exported as a separate function, not inside the config.
  2. Use the official Next.js segment config documentation to verify allowed keys and correct spelling. If using TypeScript, define the config with a typed interface to catch errors at compile time.

无效尝试

常见但无效的做法:

  1. 80% 失败

    generateStaticParams is a separate exported function, not a config key. It must be exported directly from the page file.

  2. 50% 失败

    Even if the key is valid, the value must be supported; 'edge' requires specific configuration and may not be available in all deployments.

  3. 90% 失败

    The framework validates config keys strictly; any unrecognized key triggers this error.