[英]NEXT.JS: Deployment build failed because of next lint
我正在尝试使用 Vercel 部署我的 git 存储库。 但是我的部署总是因为用于测试的文件中的 lint 错误而失败。
Vercel 文档说:
默认情况下,Next.js 将为 pages/、components/、lib/ 和 src/ 目录中的所有文件运行 ESLint。 Vercel 文档链接
所以我将我的_tests
文件夹移出我的components
文件夹,这有助于本地下一个 linter 运行npm run lint
现在运行没有任何错误,如果我是正确的,这应该反映 Vercel 部署构建的 linter。
我的棉绒设置如下:
{
"extends": "next/core-web-vitals"
}
但是当推送到主分支并部署到 vercel 时,linter 仍然在_test
文件夹中的文件上出错。
文件夹结构
_tests // Here I moved my components and tests I don't want to have errors with as they're unfinished or only tests
.next
components
lib
node_modules
pages
....
本地和 Vercel 上的 lint 进程不应该相同吗?如果不是,我如何才能像部署构建步骤那样在本地进行测试? 我错过了什么? 我查看了所有关于 eslint 的文档。
首先,我建议您即使在测试中也不要忽视 lint 问题,因为测试是应用程序的一部分。 因此,理想的世界解决方案是解决所有这些 lint 问题并感到高兴。
但是如果你仍然想排除一些代码被检查,你可以使用ESLint ignorePatterns 。 配置.eslintrc.json
可能如下所示:
{
"extends": "next/core-web-vitals",
"ignorePatterns": [
"_test/**"
]
}
或者你可以编写包含以下内容的.eslintignore
文件:
_test/
另一种可能的解决方案是next build
命令中关闭 Linter (默认情况下Vercel 使用此命令构建您的应用程序)。 为此,您需要将其添加到您的next.config.js
:
const nextConfig = {
...
eslint: {
ignoreDuringBuilds: false,
},
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.