首页 > 解决方案 > Netlify 部署失败:在“构建站点”期间失败:构建脚本返回非零退出代码:1

问题描述

我在构建我的网站时遇到问题。当我使用 Gatsby Serve 和 Gatsby Build 时一切正常,不会给我带来任何错误。我希望我有更多的细节,但不幸的是,这个错误代码并没有真正说明什么。

我在这个项目中没有 netlify.toml 或 yarn.lock。所以我不能像其他解决方案所建议的那样删除它们。

我尝试删除 package-lock.json 和 node 模块以进行新的 NPM 安装,但没有成功。

我不认为安全漏洞是问题,但我不确定。前段时间我遇到过这种情况,发现是 NPM 给了我这些问题,但这次我的修复也没有奏效。

2:11:24 PM: [feature enabled]: Nitro deploys enabled. Buckle up! ⚡️
2:11:24 PM: Build ready to start
2:11:26 PM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
2:11:26 PM: build-image tag: v3.3.5
2:11:26 PM: buildbot version: 6fd888c8d66fd09bb18f09e1728e11fbc555b868
2:11:26 PM: Fetching cached dependencies
2:11:26 PM: Starting to download cache of 188.9MB
2:11:27 PM: Finished downloading cache in 1.47346303s
2:11:27 PM: Starting to extract cache
2:11:35 PM: Finished extracting cache in 7.599019035s
2:11:35 PM: Finished fetching cache in 9.2055103s
2:11:35 PM: Starting to prepare the repo for build
2:11:36 PM: Preparing Git Reference refs/heads/master
2:11:37 PM: Starting build script
2:11:37 PM: Installing dependencies
2:11:37 PM: Started restoring cached node version
2:11:40 PM: Finished restoring cached node version
2:11:40 PM: v10.19.0 is already installed.
2:11:43 PM: Now using node v10.19.0 (npm v6.13.4)
2:11:43 PM: Attempting ruby version 2.6.2, read from environment
2:11:44 PM: Using ruby version 2.6.2
2:11:45 PM: Using PHP version 5.6
2:11:45 PM: Started restoring cached node modules
2:11:45 PM: Finished restoring cached node modules
2:11:45 PM: Installing NPM modules using NPM version 6.13.4
2:12:03 PM: npm
2:12:03 PM:  WARN rm
2:12:03 PM:  not removing /opt/build/repo/node_modules/.bin/gatsby as it wasn't installed by /opt/build/repo/node_modules/gatsby
2:12:05 PM: > gatsby-cli@2.9.0 postinstall /opt/build/repo/node_modules/gatsby-cli
2:12:05 PM: > node scripts/postinstall.js
2:12:05 PM: > gatsby@2.19.22 postinstall /opt/build/repo/node_modules/gatsby
2:12:05 PM: > node scripts/postinstall.js
2:12:06 PM: > install-peers@1.0.3 postinstall /opt/build/repo/node_modules/install-peers
2:12:06 PM: > node install.js
2:12:06 PM: Unable to find peerDependencies in /opt/build/repo
2:12:08 PM: npm
2:12:08 PM: WARN tsutils@3.17.1 requires a peer of 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 but none is installed. You must install peer dependencies yourself.
2:12:08 PM: npm WARN
2:12:08 PM: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/chokidar/node_modules/fsevents):
2:12:08 PM: npm WARN
2:12:08 PM:  notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:12:08 PM: npm WARN
2:12:08 PM:  optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
2:12:08 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:12:08 PM: added 93 packages from 905 contributors, removed 34 packages, updated 121 packages and audited 31851 packages in 22.308s
2:12:10 PM: 108 packages are looking for funding
2:12:10 PM:   run `npm fund` for details
2:12:10 PM: found 9 high severity vulnerabilities
2:12:10 PM:   run `npm audit fix` to fix them, or `npm audit` for details
2:12:10 PM: NPM modules installed
2:12:11 PM: Started restoring cached go cache
2:12:11 PM: Finished restoring cached go cache
2:12:11 PM: unset GOOS;
2:12:11 PM: unset GOARCH;
2:12:11 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
2:12:11 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
2:12:11 PM: go version >&2;
2:12:11 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
2:12:11 PM: go version go1.12 linux/amd64
2:12:11 PM: Installing missing commands
2:12:11 PM: Verify run directory
2:12:11 PM: Executing user command: gatsby build
2:12:13 PM: success open and validate gatsby-configs - 0.035s
2:12:15 PM: success load plugins - 1.430s
2:12:15 PM: success onPreInit - 0.012s
2:12:15 PM: success delete html and css files from previous builds - 0.015s
2:12:15 PM: success initialize cache - 0.009s
2:12:15 PM: success copy gatsby files - 0.032s
2:12:15 PM: success onPreBootstrap - 0.004s
2:12:15 PM: success createSchemaCustomization - 0.017s
2:12:15 PM: success source and transform nodes - 0.145s
2:12:15 PM: success building schema - 0.371s
2:12:15 PM: success createPages - 0.047s
2:12:15 PM: success createPagesStatefully - 0.064s
2:12:15 PM: success onPreExtractQueries - 0.000s
2:12:15 PM: success update schema - 0.032s
2:12:16 PM: success extract queries from components - 0.454s
2:12:16 PM: success write out requires - 0.004s
2:12:16 PM: success write out redirect data - 0.001s
2:12:16 PM: success Build manifest and related icons - 0.267s
2:12:16 PM: success onPostBootstrap - 0.268s
2:12:16 PM: ⠀
2:12:16 PM: info bootstrap finished - 5.299 s
2:12:16 PM: ⠀
2:12:38 PM: failed Building production JavaScript and CSS bundles - 21.747s
2:12:38 PM: error Generating JavaScript bundles failed
2:12:38 PM: Can't resolve '../components/Content' in '/opt/build/repo/src/templates'
2:12:38 PM: not finished run queries - 22.139s
2:12:38 PM: not finished Generating image thumbnails - 22.118s
2:12:39 PM: Skipping functions preparation step: no functions directory set
2:12:39 PM: Caching artifacts
2:12:39 PM: Started saving node modules
2:12:39 PM: Finished saving node modules
2:12:39 PM: Started saving pip cache
2:12:39 PM: Finished saving pip cache
2:12:39 PM: Started saving emacs cask dependencies
2:12:39 PM: Finished saving emacs cask dependencies
2:12:39 PM: Started saving maven dependencies
2:12:39 PM: Finished saving maven dependencies
2:12:39 PM: Started saving boot dependencies
2:12:39 PM: Finished saving boot dependencies
2:12:39 PM: Started saving go dependencies
2:12:39 PM: Finished saving go dependencies
2:12:39 PM: Error running command: Build script returned non-zero exit code: 1
2:12:39 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
2:12:39 PM: Failing build: Failed to build site
2:12:39 PM: Finished processing build request in 1m13.33817169s

标签: gatsbynetlifynetlify-cms

解决方案


我用这条线解决了

12:38 PM: Can't resolve '../components/Content' in '/opt/build/repo/src/templates'

原来这是内容被大写的语法问题。


推荐阅读