【问题标题】:Nextjs export timeout configurationNextjs导出超时配置
【发布时间】:2022-01-05 02:51:27
【问题描述】:

我正在使用 NextJS 构建一个需要一些时间来构建的网站。它必须创建一个大字典,所以当我运行 next dev 时,构建大约需要 2 分钟。

问题是,当我运行next export 来获取网站的静态版本时,会出现超时问题,因为构建需要(如我之前所说)2 分钟,超过了预先配置的 60 秒限制在下一个。

在 NEXT 文档中:https://nextjs.org/docs/messages/static-page-generation-timeout 它解释说您可以增加超时限制,默认为 60 秒:“通过更改 staticPageGenerationTimeout 配置选项来增加超时(默认为 60 秒)。”

但是它没有指定您可以在哪里设置该配置选项。在 next.config.json 中?在 package.json 中?

我在任何地方都找不到此信息,而且我盲目地尝试将此参数放入前面提到的某些文件中,但根本没有成功。那么,有人知道如何设置下一次导出的超时时间吗?提前谢谢您。

【问题讨论】:

  • 看起来它进入了next.config.json。它不适合你吗?你遇到了什么错误?
  • 面临同样的问题。将时间更改为 500 秒,但仍然出现错误。
  • 嗨,我再次尝试将以下代码放入 next.config.js:module.exports = (phase, { defaultConfig }) => { @type {import('next').NextConfig} const nextConfig = { staticPageGenerationTimeout: 2000 /* config options here */ } return nextConfig } 根据文档。但是还是不行
  • 您使用的是哪个版本的 Next.js?
  • 我正在使用 Next.js v12.0.4 。但是我发现 Next 不喜欢我使用 html 标签而不是 NextJS 中内置的 。不知道是不是这个问题,我会尽快解决,看看是不是一直都是这个问题

标签: build static next.js timeout export


【解决方案1】:

他们在文档的basic-features/data-fetching 部分更清楚地表明它应该放在next.config.js

我将它添加到我的,它工作(摆脱了Error: Collecting page data for /path/[pk] is still timing out after 2 attempts. See more info here https://nextjs.org/docs/messages/page-data-collection-timeout 构建错误):

// next.config.js
module.exports = {
  // time in seconds of no pages generating during static
  // generation before timing out
  staticPageGenerationTimeout: 1000,
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-15
    • 1970-01-01
    • 2011-12-01
    • 2021-06-09
    • 2013-02-06
    • 1970-01-01
    • 2021-07-24
    • 2021-12-28
    相关资源
    最近更新 更多