Skip to main content

eslint

当在你的项目中检测到 ESLint 时,如果存在错误,Next.js 将导致你的生产构建失败 (next build)。

¥When ESLint is detected in your project, Next.js fails your production build (next build) when errors are present.

如果你希望 Next.js 即使你的应用存在 ESLint 错误也能生成生产代码,你可以完全禁用内置的 linting 步骤。不建议这样做,除非你已经将 ESLint 配置为在工作流程的单独部分中运行(例如,在 CI 或预提交钩子中)。

¥If you'd like Next.js to produce production code even when your application has ESLint errors, you can disable the built-in linting step completely. This is not recommended unless you already have ESLint configured to run in a separate part of your workflow (for example, in CI or a pre-commit hook).

打开 next.config.js 并在 eslint 配置中启用 ignoreDuringBuilds 选项:

¥Open next.config.js and enable the ignoreDuringBuilds option in the eslint config:

module.exports = {
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
}