【问题标题】:Vague error in Vercel deployment (exit with code 1)Vercel 部署中的模糊错误(使用代码 1 退出)
【发布时间】:2021-09-12 17:38:49
【问题描述】:

所以通常 Vercel 会给我不错的错误信息,但这个似乎没有细节。只是

“失败,退出代码 1”。

就上下文而言,我刚刚使用基本的 NextJS 模板启动了这个项目,做了一些修改,这是我的第一次部署。

失败了一次,我以为是因为 NextJS 默认开启了严格的类型检查,所以我修改了next.config.js 文件如下(根据here):

module.exports = {
  typescript: {
    // !! WARN !!
    // Dangerously allow production builds to successfully complete even if
    // your project has type errors.
    // !! WARN !!
    ignoreBuildErrors: true,
  },
};

但还是失败了。这是完整的日志:

10:23:27.575    Cloning github.com/lawderp/physical (Branch: main, Commit: 8f97554)
10:23:28.589    Cloning completed: 1.014s
10:23:28.614    Analyzing source code...
10:23:29.739    Installing build runtime...
10:23:31.612    Build runtime installed: 1.873s
10:23:34.043    Looking up build cache...
10:23:34.164    Build cache found. Downloading...
10:23:35.100    Build cache downloaded [21.48 MB]: 936.007ms
10:23:36.250    Installing dependencies...
10:23:36.489    yarn install v1.22.11
10:23:36.547    [1/4] Resolving packages...
10:23:36.734    success Already up-to-date.
10:23:36.743    Done in 0.26s.
10:23:36.754    Detected Next.js version: 11.1.2
10:23:36.755    Running "yarn run build"
10:23:37.021    yarn run v1.22.11
10:23:37.047    $ next build
10:23:37.820    info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
10:23:37.976    info  - Skipping validation of types...
10:23:40.439    error Command failed with exit code 1.
10:23:40.439    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
10:23:40.456    Error: Command "yarn run build" exited with 1

【问题讨论】:

标签: next.js vercel


【解决方案1】:

仍然不确定问题出在哪里,但最终想出了如何解决这个问题 - 在构建过程中通过将以下内容添加到 next.config.js 来忽略 ESLint:

eslint: {
    ignoreDuringBuilds: true,
  },

(我不建议这样做,但这是快速的低风险实验)

【讨论】:

    【解决方案2】:

    在进行 eslint 更改后,我收到了同样模糊的信息。本地 linting 和部署是成功的,但是部署到 vercel 像你一样失败。

    虽然我的.eslint.json 中的"ignoreDuringBuilds": "true" 做了创可贴解决了这个问题,但我能够回滚每个 eslint 更改并发现我的"linebreak-style": ["error", "windows"] 是根本问题。

    它在本地通过了 linting,但在 vercel 部署上失败了。我已经修复了我的换行符,现在一切正常,在构建过程中不必忽略。

    【讨论】:

      猜你喜欢
      • 2021-04-14
      • 1970-01-01
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-14
      相关资源
      最近更新 更多