"Error running command: Build script returned non-zero exit code" 将 Gatsby JS 站点部署到 Netlify 时

"Error running command: Build script returned non-zero exit code" when deploying Gatsby JS site to Netlify

我最近遇到了 Gatsby JS (https://github.com/gatsbyjs/gatsby) 并决定在生成器之上构建我的投资组合网站。

所以我分叉了他们的入门站点 (gatsby-starter-default) 并用它构建了我的投资组合 (https://github.com/ArchieHicklin/Archie)

在本地(使用“gatsby develop”)它运行良好 - 但是当我使用“gatsby build”部署到 Netlify 时,我收到此错误:

11:30:58 AM: Build started
11:30:59 AM: Fetching cached dependencies
11:30:59 AM: Expected build cache - but failed to find it
11:30:59 AM: No cached dependencies found. Cloning fresh repo
11:30:59 AM: git clone git@github.com:ArchieHicklin/Archie /mnt/build-work/1475033459125476884/repo
11:31:00 AM: git remote rm origin /mnt/build-work/1475033459125476884/repo
11:31:00 AM: Preparing Branch
11:31:01 AM: Building site
11:31:01 AM: Running build command
11:31:02 AM: Running Build
11:31:02 AM: Building
11:31:03 AM: 0.0%
11:31:03 AM: 1.2%
11:31:04 AM: ## 3.6%
11:31:04 AM: ##### 7.
11:31:04 AM: 0%
11:31:04 AM: ######## 12.5%
11:31:04 AM: ##############
11:31:04 AM:
11:31:04 AM: 20.7%
11:31:04 AM: ###################
11:31:04 AM: 27.0%
11:31:04 AM: ############################### 44.3%
11:31:04 AM: ################################################## 70.0%
11:31:04 AM: ############################################################# 86.1%
11:31:04 AM: ########################################################################
11:31:04 AM: 100.0%
11:31:05 AM: 
11:31:05 AM: Computing checksum with sha256sum
11:31:05 AM: Checksums matched!
11:31:06 AM: Using version v4.4.2 of node
11:31:06 AM: Using /opt/buildhome/.rvm/gems/ruby-2.1.2
11:31:06 AM: Installing npm modules
11:31:07 AM: NPM modules installed
11:31:08 AM: /opt/build/build.sh: line 232: gatsby: command not found
11:31:08 AM: Cached node modules
11:31:08 AM: Cleaning up docker container
11:31:08 AM: Error running command: Build script returned non-zero exit code: 127
11:31:08 AM: Error running command: Build script returned non-zero exit code: 127

已经完成了所有标准操作,例如重新安装节点和 npm(我认为这可能是个问题)但是,几周后,我完全不知道问题是什么。同样,没有大量的在线文档如此难以确定从哪里开始解决这个问题。

任何帮助(甚至是从哪里开始重新调试的指针)将不胜感激!

构建日志抱怨未安装 gatsby,因此请确保将 gatsby 作为依赖项添加到 package.json。

最简单的方法是 运行:

npm install gatsby --save

在本地,然后将更新的 package.json 添加到您的存储库。这样 netlify 就会知道在 运行 构建命令之前安装 gatsby。

检查您是否已将 package-lock.json 文件提交到您的代码存储库。如果是这样,请将其从存储库中删除,然后再次触发部署。 发现 package-lock.json

时,Netlify 构建失败