gitlab - 如果 gatsby 站点嵌套在 repo 内的文件夹中,如何在 netlify 上部署它?
问题描述
我必须为我的大学在 netlify 上部署一个 gatsby 站点。我在 gitlab 上有一个带有两个子文件夹的仓库,它们都是单独的 gatsby 项目。部署失败,我认为是因为它尝试部署主文件夹,这不是 gatsby 项目。我将 Build 命令的“npm run build”和“gatsbyjs-starter-tailwindplay/public”插入到 Publish 目录中。这是告诉 netlify 它应该部署 gatsbyjs-starter-tailwindplay 文件夹的正确方法,而 gatsbyjs-starter-tailwindplay 是 repos 子文件夹之一?
我得到以下部署日志:
10:52:27 PM: Build ready to start
10:52:29 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
10:52:29 PM: build-image tag: v3.3.2
10:52:29 PM: buildbot version: 16db6527b4cafa2553c3f3f11aa8d1b46a72ff40
10:52:30 PM: Fetching cached dependencies
10:52:30 PM: Failed to fetch cache, continuing with build
10:52:30 PM: Starting to prepare the repo for build
10:52:31 PM: No cached dependencies found. Cloning fresh repo
10:52:31 PM: git clone git@gitlab.com:[deleted by me!]
10:52:32 PM: Preparing Git Reference refs/heads/master
10:52:32 PM: Found netlify.toml. Overriding site configuration
10:52:32 PM: Starting build script
10:52:32 PM: Installing dependencies
10:52:34 PM: Downloading and installing node v10.16.3...
10:52:34 PM: Downloading https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz...
10:52:34 PM:
#####
10:52:34 PM: 7.6%
10:52:34 PM:
#########################################
10:52:34 PM: ######################## 90.4%
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: ########################
10:52:34 PM: ############ 100.0%
10:52:34 PM: Computing checksum with sha256sum
10:52:35 PM: Checksums matched!
10:52:37 PM: Now using node v10.16.3 (npm v6.9.0)
10:52:37 PM: Attempting ruby version 2.6.2, read from environment
10:52:39 PM: Using ruby version 2.6.2
10:52:39 PM: Using PHP version 5.6
10:52:39 PM: Started restoring cached node modules
10:52:39 PM: Finished restoring cached node modules
10:52:39 PM: Installing NPM modules using NPM version 6.9.0
10:53:08 PM: > sharp@0.22.1 install /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/sharp
10:53:08 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
10:53:09 PM: info
10:53:09 PM: sharp
10:53:09 PM: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
10:53:11 PM: > core-js@2.6.9 postinstall /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/core-js
10:53:11 PM: > node scripts/postinstall || echo "ignore"
10:53:11 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
10:53:11 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
10:53:11 PM: > https://opencollective.com/core-js
10:53:11 PM: > https://www.patreon.com/zloirock
10:53:11 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
10:53:11 PM: > core-js-pure@3.1.4 postinstall /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/core-js-pure
10:53:11 PM: > node scripts/postinstall || echo "ignore"
10:53:11 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
10:53:11 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
10:53:11 PM: > https://opencollective.com/core-js
10:53:11 PM: > https://www.patreon.com/zloirock
10:53:11 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
10:53:12 PM: > gatsby-telemetry@1.1.0 postinstall /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/gatsby-telemetry
10:53:12 PM: > node src/postinstall.js
10:53:14 PM: npm
10:53:14 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
10:53:14 PM: npm
10:53:14 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:53:14 PM: added 1591 packages from 877 contributors and audited 21387 packages in 33.175s
10:53:14 PM: found 529 vulnerabilities (527 high, 2 critical)
10:53:14 PM: run `npm audit fix` to fix them, or `npm audit` for details
10:53:14 PM: NPM modules installed
10:53:14 PM: Started restoring cached go cache
10:53:14 PM: Finished restoring cached go cache
10:53:14 PM: unset GOOS;
10:53:14 PM: unset GOARCH;
10:53:14 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
10:53:14 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
10:53:14 PM: go version >&2;
10:53:14 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
10:53:14 PM: go version go1.12 linux/amd64
10:53:14 PM: Installing missing commands
10:53:14 PM: Verify run directory
10:53:14 PM: Executing user command: npm run build
10:53:14 PM: > @oddstronaut/gatsby-starter-tailwind@3.0.25 build /opt/build/repo/gatsbyjs-starter-tailwindplay
10:53:14 PM: > yarn run clean && gatsby build
10:53:14 PM: sh: 1: yarn: not found
10:53:14 PM: npm
10:53:14 PM: ERR! file sh
10:53:14 PM: npm ERR! code ELIFECYCLE
10:53:14 PM: npm ERR! errno
10:53:14 PM: ENOENT
10:53:14 PM: npm ERR! syscall spawn
10:53:14 PM: npm
10:53:14 PM: ERR! @oddstronaut/gatsby-starter-tailwind@3.0.25 build: `yarn run clean && gatsby build`
10:53:14 PM: npm ERR! spawn ENOENT
10:53:14 PM: npm ERR!
10:53:14 PM: npm ERR! Failed at the @oddstronaut/gatsby-starter-tailwind@3.0.25 build script.
10:53:14 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:53:14 PM: npm
10:53:14 PM: ERR! A complete log of this run can be found in:
10:53:14 PM: npm ERR!
10:53:14 PM: /opt/buildhome/.npm/_logs/2019-10-03T20_53_14_985Z-debug.log
10:53:14 PM: Skipping functions preparation step: no functions directory set
10:53:14 PM: Caching artifacts
10:53:14 PM: Started saving node modules
10:53:15 PM: Finished saving node modules
10:53:15 PM: Started saving pip cache
10:53:15 PM: Finished saving pip cache
10:53:15 PM: Started saving emacs cask dependencies
10:53:15 PM: Finished saving emacs cask dependencies
10:53:15 PM: Started saving maven dependencies
10:53:15 PM: Finished saving maven dependencies
10:53:15 PM: Started saving boot dependencies
10:53:15 PM: Finished saving boot dependencies
10:53:15 PM: Started saving go dependencies
10:53:15 PM: Finished saving go dependencies
10:53:17 PM: Error running command: Build script returned non-zero exit code: 1
10:53:17 PM: Failing build: Failed to build site
10:53:17 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
10:53:18 PM: Finished processing build request in 48.202499427s
但是,如果我进入 gatsbyjs-starter-tailwindplay 文件夹,则没有公用文件夹,但它肯定存在于我 PC 上的克隆存储库中!对 git 没有超级经验,应该是这样。对于只有默认 gatsby 起始页的 repo 也是一样的,我可以很好地部署它,所以我认为它应该是这样的?!
解决方案
如果您netlify.toml
在存储库根目录中添加文件会发生什么?
# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
base = "gatsbyjs-starter-tailwindplay/"
# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build. If a base directory has
# been specified, include it in the publish directory path.
publish = "gatsbyjs-starter-tailwindplay/public/"
# Default build command.
command = "npm run build"
和文件夹是 gatsby 构建过程的结果public
。.cache
它们被设置为被.gitignore
文件中的 git 忽略。
推荐阅读
- twitter-bootstrap - 变换动画不适用于引导轮播中的第一张幻灯片
- javascript - 单击功能应用于具有相同类的所有 div
- .net - 迁移到较新的框架版本是否可以解决安全问题
- javascript - 从循环中停止逐行javascript动画
- microsoft-graph-api - 通过 MS Graph API 返回用户的employeeId
- json - Mule 3.9 Dataweave 从整数中删除 .00
- c++ - Xerces-C 使用硬编码的 xsd 验证 xml
- nginx - 缓存在使用 proxy_cache 的 nginx 中不起作用。
- c# - 向 USB/以太网连接设备发送多个命令
- php - Laravel 在注册时插入两条用户记录,如何防止这种情况?