Netlify 部署:12:43:01 AM:由于用户错误,构建失败:构建脚本返回非零退出代码:2

问题描述 投票:0回答:2

我正在尝试将 gatsby 网站的更改部署到 netlify,我已经合并了一些更改,并且该网站在本地运行这些更改,但是当我尝试部署它时,我收到此错误:

12:43:01 AM:由于用户错误,构建失败:构建脚本返回非零退出代码:2,

这是我的输出,我不确定为什么会发生这种情况,有什么建议吗?

12:41:26 AM: Build ready to start
12:41:29 AM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
12:41:29 AM: build-image tag: v3.6.0
12:41:29 AM: buildbot version: dc0a2b81d00d8f0151c0b6d6eab301febfb9ab68
12:41:29 AM: Building without cache
12:41:29 AM: Starting to prepare the repo for build
12:41:29 AM: No cached dependencies found. Cloning fresh repo
12:41:29 AM: git clone https://github.com/Ropenfold/ShenleySYS-Website
12:41:31 AM: Preparing Git Reference refs/heads/master
12:41:32 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
12:41:32 AM: Starting build script
12:41:32 AM: Installing dependencies
12:41:32 AM: Python version set to 2.7
12:41:33 AM: v12.18.0 is already installed.
12:41:34 AM: Now using node v12.18.0 (npm v6.14.4)
12:41:34 AM: Started restoring cached build plugins
12:41:34 AM: Finished restoring cached build plugins
12:41:34 AM: Attempting ruby version 2.7.1, read from environment
12:41:35 AM: Using ruby version 2.7.1
12:41:36 AM: Using PHP version 5.6
12:41:36 AM: Started restoring cached node modules
12:41:36 AM: Finished restoring cached node modules
12:41:36 AM: Started restoring cached yarn cache
12:41:36 AM: Finished restoring cached yarn cache
12:41:36 AM: Installing yarn at version 1.22.4
12:41:36 AM: Installing Yarn!
12:41:36 AM: > Downloading tarball...
12:41:36 AM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.ZaNAZ77FBN
12:41:36 AM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
12:41:36 AM:                                  Dload  Upload   Total   Spent    Left  Speed
12:41:36 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
12:41:36 AM: 100    80  100    80    0     0    236      0 --:--:-- --:--:-- --:--:--   236
12:41:36 AM: 100    93  100    93    0     0    136      0 --:--:-- --:--:-- --:--:--   136
12:41:37 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
12:41:37 AM: 100   643  100   643    0     0    627      0  0:00:01  0:00:01 --:--:--  4984
12:41:37 AM: 100 1215k  100 1215k    0     0   831k      0  0:00:01  0:00:01 --:--:--  831k
12:41:37 AM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.ZaNAZ77FBN.asc
12:41:37 AM: 100    84  100    84    0     0   2950      0 --:--:-- --:--:-- --:--:--  2950
12:41:37 AM: 100    97  100    97    0     0   1738      0 --:--:-- --:--:-- --:--:--  1738
12:41:37 AM: 100   647  100   647    0     0   3488      0 --:--:-- --:--:-- --:--:--  3488
12:41:37 AM: 100  1028  100  1028    0     0   4394      0 --:--:-- --:--:-- --:--:--  4394
12:41:37 AM: > Verifying integrity...
12:41:37 AM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
12:41:37 AM: gpg: Good signature from "Yarn Packaging <[email protected]>"
12:41:37 AM: gpg: WARNING: This key is not certified with a trusted signature!
12:41:37 AM: gpg:          There is no indication that the signature belongs to the owner.
12:41:37 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
12:41:37 AM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
12:41:37 AM: > GPG signature looks good
12:41:37 AM: > Extracting to ~/.yarn...
12:41:37 AM: > Adding to $PATH...
12:41:38 AM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
12:41:38 AM: Installing NPM modules using Yarn version 1.22.4
12:41:39 AM: yarn install v1.22.4
12:41:39 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
12:41:39 AM: [1/4] Resolving packages...
12:41:40 AM: [2/4] Fetching packages...
12:41:45 AM: warning [email protected]: Invalid bin field for "url-loader".
12:42:09 AM: info [email protected]: The platform "linux" is incompatible with this module.
12:42:09 AM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
12:42:09 AM: info [email protected]: The platform "linux" is incompatible with this module.
12:42:09 AM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
12:42:09 AM: [3/4] Linking dependencies...
12:42:09 AM: warning "gatsby > @typescript-eslint/eslint-plugin > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
12:42:09 AM: warning "gatsby > eslint-plugin-graphql > graphql-config > @endemolshinegroup/cosmiconfig-typescript-loader > [email protected]" has unmet peer dependency "typescript@>=2.7".
12:42:09 AM: warning "gatsby-plugin-sass > [email protected]" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
12:42:09 AM: warning " > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
12:42:25 AM: [4/4] Building fresh packages...
12:42:35 AM: success Saved lockfile.
12:42:35 AM: Done in 56.33s.
12:42:35 AM: NPM modules installed using Yarn
12:42:35 AM: Started restoring cached go cache
12:42:35 AM: Finished restoring cached go cache
12:42:35 AM: go version go1.14.4 linux/amd64
12:42:35 AM: go version go1.14.4 linux/amd64
12:42:35 AM: Installing missing commands
12:42:35 AM: Verify run directory
12:42:37 AM: ​
12:42:37 AM: ────────────────────────────────────────────────────────────────
12:42:37 AM:   Netlify Build                                                 
12:42:37 AM: ────────────────────────────────────────────────────────────────
12:42:37 AM: ​
12:42:37 AM: ❯ Version
12:42:37 AM:   @netlify/build 8.0.0
12:42:37 AM: ​
12:42:37 AM: ❯ Flags
12:42:37 AM:   deployId: 5fdd4c3688a7e51717c19c15
12:42:37 AM:   mode: buildbot
12:42:37 AM: ​
12:42:37 AM: ❯ Current directory
12:42:37 AM:   /opt/build/repo
12:42:37 AM: ​
12:42:37 AM: ❯ Config file
12:42:37 AM:   No config file was defined: using default values.
12:42:37 AM: ​
12:42:37 AM: ❯ Context
12:42:37 AM:   production
12:42:37 AM: ​
12:42:37 AM: ────────────────────────────────────────────────────────────────
12:42:37 AM:   1. Build command from Netlify app                             
12:42:37 AM: ────────────────────────────────────────────────────────────────
12:42:37 AM: ​
12:42:37 AM: $ gatsby build
12:42:40 AM: success open and validate gatsby-configs - 0.021s
12:42:41 AM: warning Warning: there are unknown plugin options for "gatsby-remark-images": linkImagesTooOriginal
12:42:41 AM: Please open an issue at ghub.io/gatsby-remark-images if you believe this option is valid.
12:42:41 AM: success load plugins - 0.948s
12:42:42 AM: success onPreInit - 0.101s
12:42:42 AM: success delete html and css files from previous builds - 0.003s
12:42:42 AM: success initialize cache - 0.008s
12:42:42 AM: success copy gatsby files - 0.032s
12:42:42 AM: success onPreBootstrap - 0.017s
12:42:42 AM: success createSchemaCustomization - 0.024s
12:42:42 AM: success Contentful: Fetch data (eji95rahg2da-master) - 0.327s
12:42:42 AM: info Updated entries 4
12:42:42 AM: info Deleted entries 0
12:42:42 AM: info Updated assets 8
12:42:42 AM: info Deleted assets 0
12:42:42 AM: success Contentful: Proccess data (eji95rahg2da-master) - 0.023s
12:42:42 AM: info Creating 2 Contentful News Item nodes
12:42:42 AM: info Creating 2 Contentful Player Profile nodes
12:42:42 AM: info Creating 8 Contentful asset nodes
12:42:42 AM: success Contentful: Create nodes (eji95rahg2da-master) - 0.019s
12:42:42 AM: success Checking for changed pages - 0.000s
12:42:42 AM: success source and transform nodes - 0.585s
12:42:43 AM: success building schema - 0.542s
12:42:43 AM: info Total nodes: 88, SitePage nodes: 3 (use --verbose for breakdown)
12:42:43 AM: success createPages - 0.033s
12:42:43 AM: success Checking for changed pages - 0.000s
12:42:43 AM: success createPagesStatefully - 0.078s
12:42:43 AM: success update schema - 0.038s
12:42:43 AM: success onPreExtractQueries - 0.002s
12:42:43 AM: success extract queries from components - 0.500s
12:42:43 AM: success write out redirect data - 0.001s
12:42:43 AM: success onPostBootstrap - 0.000s
12:42:43 AM: info bootstrap finished - 6.129s
12:42:44 AM: success run static queries - 0.034s - 5/5 148.92/s
12:42:44 AM: success run page queries - 0.016s - 9/9 571.02/s
12:42:44 AM: success write out requires - 0.004s
12:42:58 AM: failed Building production JavaScript and CSS bundles - 14.703s
12:42:58 AM: error undefined failed
12:42:58 AM: Can't resolve '../../public/images/Logo.png' in '/opt/build/repo/src/templates'
12:42:58 AM: If you're trying to use a package make sure that '../../public/images/Logo.png' is installed. If you're trying to use a local file make sure that the path is correct.
12:42:58 AM: ​
12:42:58 AM: ────────────────────────────────────────────────────────────────
12:42:58 AM:   "build.command" failed                                        
12:42:58 AM: ────────────────────────────────────────────────────────────────
12:42:58 AM: ​
12:42:58 AM:   Error message
12:42:58 AM:   Command failed with exit code 1: gatsby build
12:42:58 AM: ​
12:42:58 AM:   Error location
12:42:58 AM:   In Build command from Netlify app:
12:42:58 AM:   gatsby build
12:42:58 AM: ​
12:42:58 AM:   Resolved config
12:42:58 AM:   build:
12:42:58 AM:     command: gatsby build
12:42:58 AM:     commandOrigin: ui
12:42:58 AM:     environment:
12:42:58 AM:       - GATSBY_CONTENTFUL_ACCESS_TOKEN
12:42:58 AM:       - GATSBY_CONTENTFUL_SPACE_ID
12:42:58 AM:       - GATSBY_GRAPHQL_IDE
12:42:58 AM:     publish: /opt/build/repo/public
12:42:58 AM: Caching artifacts
12:42:58 AM: Started saving node modules
12:42:58 AM: Finished saving node modules
12:42:58 AM: Started saving build plugins
12:42:58 AM: Finished saving build plugins
12:42:58 AM: Started saving yarn cache
12:42:58 AM: Finished saving yarn cache
12:42:58 AM: Started saving pip cache
12:42:59 AM: Finished saving pip cache
12:42:59 AM: Started saving emacs cask dependencies
12:42:59 AM: Finished saving emacs cask dependencies
12:42:59 AM: Started saving maven dependencies
12:42:59 AM: Finished saving maven dependencies
12:42:59 AM: Started saving boot dependencies
12:42:59 AM: Finished saving boot dependencies
12:42:59 AM: Started saving rust rustup cache
12:42:59 AM: Finished saving rust rustup cache
12:42:59 AM: Started saving rust cargo bin cache
12:42:59 AM: Finished saving rust cargo bin cache
12:42:59 AM: Started saving go dependencies
12:42:59 AM: Finished saving go dependencies
12:43:01 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:43:01 AM: Failing build: Failed to build site
12:43:01 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:43:01 AM: Finished processing build request in 1m32.525419092s
node.js reactjs gatsby netlify netlify-cms
2个回答
2
投票

这是关键行:

12:42:58 AM:无法解析 '../../public/images/Logo.png' '/opt/build/repo/src/templates'

templates
中,您正在使用
../../public/images/Logo.png
,它似乎未定义或未解析。检查路径,因为通常,当使用相对路径(
../../
)时,转换无法正确完成。还要检查您的项目是否也在本地构建而没有问题。

我不知道你的项目中是否使用了 Netlify CMS,如果是的话,在

config.yml
中,你的
media_folder
和你的
public_folder
应该看起来像这样:

media_folder: static/assets/images
public_folder: /assets/images

请注意,没有相对路径和

/
的起始斜杠 (
public_folder
)。当然,你可以省略
/assets/
中间件,直接指向
/images/

这是因为在 Netlify 中处理上传的图像时,您需要将它们下载到

/static
文件夹,以允许 Gatsby 将它们转译到
/public
输出文件夹,使它们可用于您的代码。


0
投票
  1. 转到站点配置 > 构建和部署 > 持续部署 > 构建设置 > 编辑(配置)。
  2. 将构建命令编辑为 CI= npm run build(带空格的精确单词)。
  3. 转到环境变量> 添加变量。添加 Key=CI 和 value=false
  4. 毕竟我遇到了同样的错误。所以我将更改安装在本地系统上的节点版本。
  5. 转到站点配置 > 构建和部署 > 持续部署 > 依赖关系管理 > 编辑(配置) > Node.js 版本。 [16.x] > 保存..
  6. 再次转到部署 > 触发部署 > 清除缓存并部署站点..
© www.soinside.com 2019 - 2024. All rights reserved.