由于退出错误状态 127,在 netlify 上构建 Hugo 站点时出错

Error in building a Hugo site on netlify because of exit error status 127

我正在使用 Hugo、netlify 和 github 构建一个静态站点。 但是我在最后一行收到关于建筑站点脚本的错误,退出代码为 127。 这是什么脚本,我该如何解决这个问题。 LINK -Github repo 我是一个非常初学者。 提前致谢

    5:10:09 PM: Build ready to start
5:10:10 PM: build-image version: 42bca793ccd33055023c56c4ca8510463a56d317
5:10:10 PM: buildbot version: 15854c92f1b74f9c77ad951b5536193c76eff25e
5:10:11 PM: Fetching cached dependencies
5:10:11 PM: Starting to download cache of 16.7MB
5:10:11 PM: Finished downloading cache in 209.623278ms
5:10:11 PM: Starting to extract cache
5:10:11 PM: Finished extracting cache in 184.94328ms
5:10:11 PM: Finished fetching cache in 452.033931ms
5:10:11 PM: Starting to prepare the repo for build
5:10:11 PM: Preparing Git Reference refs/heads/master
5:10:12 PM: Starting build script
5:10:12 PM: Installing dependencies
5:10:13 PM: Downloading and installing node v8.12.0...
5:10:13 PM: Downloading https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz...
5:10:14 PM:   0.9%
5:10:14 PM: 
#####################
5:10:14 PM:                                                     30.3%
5:10:14 PM: 
#################################
5:10:14 PM: ####################################### 100.0%
5:10:14 PM: Computing checksum with sha256sum
5:10:14 PM: Checksums matched!
5:10:16 PM: Now using node v8.12.0 (npm v6.4.1)
5:10:17 PM: Attempting ruby version 2.3.6, read from environment
5:10:18 PM: Using ruby version 2.3.6
5:10:18 PM: Using PHP version 5.6
5:10:18 PM: Installing Hugo 0.41
5:10:19 PM: Started restoring cached go cache
5:10:19 PM: Finished restoring cached go cache
5:10:19 PM: unset GOOS;
5:10:19 PM: unset GOARCH;
5:10:19 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';
5:10:19 PM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";
5:10:19 PM: go version >&2;
5:10:20 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';
5:10:20 PM: go version go1.10 linux/amd64
5:10:20 PM: Installing missing commands
5:10:20 PM: Verify run directory
5:10:20 PM: Executing user command: hugo_0.41
5:10:20 PM: /usr/local/bin/build: line 32: hugo_0.41: command not found
5:10:20 PM: Caching artifacts
5:10:20 PM: Started saving pip cache
5:10:20 PM: Finished saving pip cache
5:10:20 PM: Started saving emacs cask dependencies
5:10:20 PM: Finished saving emacs cask dependencies
5:10:20 PM: Started saving maven dependencies
5:10:20 PM: Finished saving maven dependencies
5:10:20 PM: Started saving boot dependencies
5:10:20 PM: Finished saving boot dependencies
5:10:20 PM: Started saving go dependencies
5:10:20 PM: Finished saving go dependencies
5:10:20 PM: Cached node version v8.12.0
5:10:20 PM: Error running command: Build script returned non-zero exit code: 127
5:10:20 PM: Failing build: Failed to build site
5:10:20 PM: failed during stage 'building site': Build script returned non-zero exit code: 127
5:10:20 PM: Finished processing build request in 9.957599589s

Netlify 使用的命令 hugo_0.41 构建不正确 Hugo

Executing user command: hugo_0.41

当存在非零退出代码时,您的站点构建将失败并且不会部署。

Error running command: Build script returned non-zero exit code: 127

解决方案

通过 运行 生产构建的正确命令 hugo 解决此问题。还要将 Hugo 版本设置为目标版本,看起来是 version 0.41

从您的存储库控制它的最简单方法是在存储库的根目录中创建一个 netlify.toml 文件。

netlify.toml

[build]
  command = "hugo"
  publish = "public"

[build.environment]
  HUGO_VERSION = "0.41"

注意: netlify.toml 中的值也可以在 app.netlify.com 在线管理中设置,但 netlify.toml 将覆盖这些值也可以在以后用于更高级的设置。您还可以通过 .

测试不同版本的 Hugo