Netlify 部署(Nuxt - Storyblok CMS 项目)失败。 `在 'building site' 阶段失败:构建脚本返回非零退出代码:1`

Netlify Deployment (Nuxt - Storyblok CMS project) failure. `Failed during stage 'building site': Build script returned non-zero exit code: 1`

已解决!查看下面的更多详细信息。 (这是一个打字错误)





我正在尝试使用 npm run generate 在 Netlify 中将项目部署为静态项目,但出现 failed during stage 'building site': Build script returned non-zero exit code: 1 错误。我之前在 Netlify 中部署了另外 2 个项目(他们没有使用 Storyblok,只使用 Nuxt)并且我之前没有遇到过这样的错误。

该项目使用 Nuxt Js(Vue Js 框架)、Vuetify 和 Storyblok Headless CMS,使用 asyncData 方法调用请求。我已经按照 Storyblok 的文档所说的方式实现了它,尤其是 nuxt.config.js 中路由的生成,version(草稿 - 已发布)的动态更改,使用 storyblok-nuxt 请求模块,设置 Storyblok space 并创建令牌(草稿 - 已发布),所需的组件和内容。

一切正常,在本地作为 npm run dev(开发模式)和使用 npm run generate(本地生产模式)。我使用 http-server 测试了第二个,它完全正常工作。

我试过了:

1).重新部署甚至没有缓存。

2). 运行 在本地 npm run audit 然后 npm run audit fix 修复一些漏洞(以检查它们是否是问题所在)。

3).将 Nuxt 更新到最新版本(我认为是 2.4.0,我更新到 2.8.1。

4).我还尝试在 nuxt.config.js 中注释掉动态路由的生成(因此只会生成标准路由)以查看动态路由是否是问题所在,但仍然出现类似的错误。

Netlify 部署中的完整日志是:

8:04:24 PM: Build ready to start
8:04:26 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
8:04:26 PM: build-image tag: v3.3.2
8:04:26 PM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045
8:04:26 PM: Fetching cached dependencies
8:04:26 PM: Starting to download cache of 255.0KB
8:04:26 PM: Finished downloading cache in 92.256738ms
8:04:26 PM: Starting to extract cache
8:04:26 PM: Failed to fetch cache, continuing with build
8:04:26 PM: Starting to prepare the repo for build
8:04:27 PM: No cached dependencies found. Cloning fresh repo
8:04:27 PM: git clone https://github.com/alexgil1994/sofokliskourtidis
8:04:28 PM: Preparing Git Reference refs/heads/master
8:04:28 PM: Starting build script
8:04:28 PM: Installing dependencies
8:04:29 PM: Downloading and installing node v10.16.0...
8:04:30 PM: Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz...
8:04:30 PM: 
################################
8:04:30 PM:                            44.9%
8:04:30 PM: 
##################################################
8:04:30 PM: ###################### 100.0%
8:04:30 PM: Computing checksum with sha256sum
8:04:30 PM: Checksums matched!
8:04:33 PM: Now using node v10.16.0 (npm v6.9.0)
8:04:33 PM: Attempting ruby version 2.6.2, read from environment
8:04:34 PM: Using ruby version 2.6.2
8:04:35 PM: Using PHP version 5.6
8:04:35 PM: Started restoring cached node modules
8:04:35 PM: Finished restoring cached node modules
8:04:35 PM: Installing NPM modules using NPM version 6.9.0
8:04:59 PM: > core-js-pure@3.1.3 postinstall /opt/build/repo/node_modules/core-js-pure
8:04:59 PM: > node scripts/postinstall || echo "ignore"
8:04:59 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
8:04:59 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
8:04:59 PM: > https://opencollective.com/core-js 
8:04:59 PM: > https://www.patreon.com/zloirock 
8:04:59 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
8:04:59 PM: > nodemon@1.19.0 postinstall /opt/build/repo/node_modules/nodemon
8:04:59 PM: > node bin/postinstall || exit 0
8:04:59 PM: Love nodemon? You can now support the project via the open collective:
8:04:59 PM:  > https://opencollective.com/nodemon/donate
8:04:59 PM: > nuxt@2.8.1 postinstall /opt/build/repo/node_modules/nuxt
8:04:59 PM: > opencollective || exit 0
8:05:00 PM:                                      :-:
8:05:00 PM:                                    .==-+:
8:05:00 PM:                                   .==. :+- .-=-
8:05:00 PM:                                  .==.   :==++-+=.
8:05:00 PM:                                 :==.     -**: :+=.
8:05:00 PM:                                :+-      :*+++. .++.
8:05:00 PM:                               :+-      -*= .++: .=+.
8:05:00 PM:                              -+:      =*-   .+*: .=+:
8:05:00 PM:                             -+:     .=*-     .=*-  =+:
8:05:00 PM:                           .==:     .+*:        -*-  -+-
8:05:00 PM:                          .=+:.....:+*-.........:=*=..=*-
8:05:00 PM:                          .-=------=++============++====:
8:05:00 PM:                           Thanks for installing nuxtjs
8:05:00 PM:                  Please consider donating to our open collective
8:05:00 PM:                         to help us maintain this package.
8:05:00 PM:                            Number of contributors: 204
8:05:00 PM:                               Number of backers: 217
8:05:00 PM:                               Annual budget: ,368
8:05:00 PM:                              Current balance: ,815
8:05:00 PM:                  Donate: https://opencollective.com/nuxtjs/donate
8:05:01 PM: npm WARN
8:05:01 PM: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.7 (node_modules/@nuxt/builder/node_modules/fsevents):
8:05:01 PM: npm
8:05:01 PM:  WARN notsup
8:05:01 PM:  SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.0.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
8:05:01 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
8:05:01 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
8:05:01 PM: added 1178 packages from 583 contributors and audited 13223 packages in 25.237s
8:05:01 PM: found 0 vulnerabilities
8:05:01 PM: NPM modules installed
8:05:01 PM: Started restoring cached go cache
8:05:01 PM: Finished restoring cached go cache
8:05:02 PM: unset GOOS;
8:05:02 PM: unset GOARCH;
8:05:02 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
8:05:02 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
8:05:02 PM: go version >&2;
8:05:02 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
8:05:02 PM: go version go1.12 linux/amd64
8:05:02 PM: Installing missing commands
8:05:02 PM: Verify run directory
8:05:02 PM: Executing user command: npm run generate
8:05:02 PM: > sofokliskourtidis@1.0.0 generate /opt/build/repo
8:05:02 PM: > nuxt generate
8:05:05 PM: ℹ Production build
8:05:05 PM: ✔ Builder initialized
8:05:05 PM: ✔ Nuxt files generated
8:05:08 PM: ℹ Compiling Client
8:05:57 PM: ✔ Client: Compiled with some errors in 49.73s
8:05:57 PM: Hash: e377ffadaa01340e2904
8:05:57 PM: Version: webpack 4.33.0
8:05:57 PM: Time: 49736ms
8:05:57 PM: Built at: 06/11/2019 5:05:57 PM
8:05:57 PM:                                Asset       Size  Chunks  Chunk Names
8:05:57 PM:              05d6065413b138f1d7e5.js   11.9 KiB       8  pages/articles/posts/tags/_tag/page/_pageNum
8:05:57 PM:              0c60ef31c5ef98553702.js   6.12 KiB      38  pages/regional/posts/overview/index
8:05:57 PM:              11941b79ce20754bb795.js   1.65 KiB      31  pages/photography/posts/_id
8:05:57 PM:              14737906e17b8a20ffe4.js   4.83 KiB       9  pages/articles/posts/tags/index
8:05:57 PM:              16748f01034580cf9a1f.js   11.9 KiB      15  pages/literature-poetry/posts/search/page/_pageNum
8:05:57 PM:              16e42f3698c4cf474170.js   1.62 KiB      19  pages/movies/posts/_id
8:05:57 PM:              17399e159d7a5c9fd4ed.js   11.8 KiB      27  pages/music/posts/search/page/_pageNum
8:06:00 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
8:05:57 PM:              2cf93be146656923f6a9.js   1.69 KiB      13  pages/literature-poetry/posts/_id
8:05:57 PM:              300ad3ecf659adc49691.js   2.14 KiB       3  pages/about
8:05:57 PM:              498a6373a91c5639c50c.js   1.61 KiB      25  pages/music/posts/_id
8:06:01 PM: Shutting down logging, 104 messages pending

期望看到正在生成的所有路由(正常路由和动态路由),我相信崩溃发生在任何路由创建之前(这发生在生成的后期。另外我想说的是每次重新部署时抛出崩溃的那一刻都不一样,它在相似的地点和时间但是它也发生了这样的事情或(有点远)而且更早但总是在客户之后一代发生:

11:11:57 PM: Build ready to start
11:11:59 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
11:11:59 PM: build-image tag: v3.3.2
11:11:59 PM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045
11:12:00 PM: Fetching cached dependencies
11:12:00 PM: Failed to fetch cache, continuing with build
11:12:00 PM: Starting to prepare the repo for build
11:12:00 PM: No cached dependencies found. Cloning fresh repo
11:12:00 PM: git clone https://github.com/alexgil1994/sofokliskourtidis
11:12:05 PM: Preparing Git Reference refs/heads/master
11:12:07 PM: Starting build script
11:12:07 PM: Installing dependencies
11:12:08 PM: Downloading and installing node v10.16.0...
11:12:09 PM: Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz...
11:12:09 PM: 
################
11:12:09 PM:    22.7%
11:12:09 PM: 
#########################################
11:12:09 PM: ###################              84.0%
11:12:09 PM: 
######################################################################## 100.0%
11:12:09 PM: Computing checksum with sha256sum
11:12:09 PM: Checksums matched!
11:12:12 PM: Now using node v10.16.0 (npm v6.9.0)
11:12:12 PM: Attempting ruby version 2.6.2, read from environment
11:12:13 PM: Using ruby version 2.6.2
11:12:13 PM: Using PHP version 5.6
11:12:13 PM: Started restoring cached node modules
11:12:13 PM: Finished restoring cached node modules
11:12:14 PM: Installing NPM modules using NPM version 6.9.0
11:12:36 PM: > core-js-pure@3.1.3 postinstall /opt/build/repo/node_modules/core-js-pure
11:12:36 PM: > node scripts/postinstall || echo "ignore"
11:12:37 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
11:12:37 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
11:12:37 PM: > https://opencollective.com/core-js 
11:12:37 PM: > https://www.patreon.com/zloirock 
11:12:37 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
11:12:37 PM: > nodemon@1.19.0 postinstall /opt/build/repo/node_modules/nodemon
11:12:37 PM: > node bin/postinstall || exit 0
11:12:37 PM: Love nodemon? You can now support the project via the open collective:
11:12:37 PM:  > https://opencollective.com/nodemon/donate
11:12:37 PM: > nuxt@2.8.1 postinstall /opt/build/repo/node_modules/nuxt
11:12:37 PM: > opencollective || exit 0
11:12:37 PM:                                      :-:
11:12:37 PM:                                    .==-+:
11:12:37 PM:                                   .==. :+- .-=-
11:12:37 PM:                                  .==.   :==++-+=.
11:12:37 PM:                                 :==.     -**: :+=.
11:12:37 PM:                                :+-      :*+++. .++.
11:12:37 PM:                               :+-      -*= .++: .=+.
11:12:37 PM:                              -+:      =*-   .+*: .=+:
11:12:37 PM:                             -+:     .=*-     .=*-  =+:
11:12:37 PM:                           .==:     .+*:        -*-  -+-
11:12:37 PM:                          .=+:.....:+*-.........:=*=..=*-
11:12:37 PM:                          .-=------=++============++====:
11:12:37 PM:                           Thanks for installing nuxtjs
11:12:37 PM:                  Please consider donating to our open collective
11:12:37 PM:                         to help us maintain this package.
11:12:37 PM:                            Number of contributors: 204
11:12:37 PM:                               Number of backers: 217
11:12:37 PM:                               Annual budget: ,368
11:12:37 PM:                              Current balance: ,815
11:12:37 PM:                  Donate: https://opencollective.com/nuxtjs/donate
11:12:39 PM: npm
11:12:39 PM:  WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.7 (node_modules/@nuxt/builder/node_modules/fsevents):
11:12:39 PM: npm WARN
11:12:39 PM: notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.0.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
11:12:39 PM: npm
11:12:39 PM:  WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
11:12:39 PM: npm
11:12:39 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
11:12:39 PM: added 1178 packages from 583 contributors and audited 13223 packages in 24.18s
11:12:39 PM: found 0 vulnerabilities
11:12:39 PM: NPM modules installed
11:12:39 PM: Started restoring cached go cache
11:12:39 PM: Finished restoring cached go cache
11:12:39 PM: unset GOOS;
11:12:39 PM: unset GOARCH;
11:12:39 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
11:12:39 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
11:12:39 PM: go version >&2;
11:12:39 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
11:12:39 PM: go version go1.12 linux/amd64
11:12:39 PM: Installing missing commands
11:12:39 PM: Verify run directory
11:12:39 PM: Executing user command: npm run generate
11:12:39 PM: > sofokliskourtidis@1.0.0 generate /opt/build/repo
11:12:39 PM: > nuxt generate
11:12:42 PM: ℹ Production build
11:12:43 PM: ✔ Builder initialized
11:12:43 PM: ✔ Nuxt files generated
11:12:45 PM: ℹ Compiling Client
11:13:38 PM: ✔ Client: Compiled with some errors in 53.34s
11:13:38 PM: Hash: e377ffadaa01340e2904
11:13:38 PM: Version: webpack 4.33.0
11:13:38 PM: Time: 53344ms
11:13:38 PM: Built at: 06/11/2019 8:13:38 PM
11:13:38 PM:                                Asset       Size  Chunks  Chunk Names
11:13:38 PM:              05d6065413b138f1d7e5.js   11.9 KiB       8  pages/articles/posts/tags/_tag/page/_pageNum
11:13:38 PM:              0c60ef31c5ef98553702.js   6.12 KiB      38  pages/regional/posts/overview/index
11:13:38 PM:              11941b79ce20754bb795.js   1.65 KiB      31  pages/photography/posts/_id
11:13:38 PM:              14737906e17b8a20ffe4.js   4.83 KiB       9  pages/articles/posts/tags/index
11:13:38 PM:              16748f01034580cf9a1f.js   11.9 KiB      15  pages/literature-poetry/posts/search/page/_pageNum
11:13:38 PM:              16e42f3698c4cf474170.js   1.62 KiB      19  pages/movies/posts/_id
11:13:38 PM:              17399e159d7a5c9fd4ed.js   11.8 KiB      27  pages/music/posts/search/page/_pageNum
11:13:38 PM:              2cf93be146656923f6a9.js   1.69 KiB      13  pages/literature-poetry/posts/_id
11:13:38 PM:              300ad3ecf659adc49691.js   2.14 KiB       3  pages/about
11:13:38 PM:              498a6373a91c5639c50c.js   1.61 KiB      25  pages/music/posts/_id
11:13:38 PM:              4e7c5059bd22566047bc.js   11.9 KiB      22  pages/movies/posts/tags/_tag/page/_pageNum
11:13:38 PM:              5703fdcb34c21e9010b9.js   6.02 KiB      20  pages/movies/posts/overview/index
11:13:38 PM:              590c5bb6b402a8e95872.js   6.25 KiB      10  pages/contact
11:13:38 PM:              5f172f247c5bdae3d529.js   11.8 KiB      21  pages/movies/posts/search/page/_pageNum
11:13:38 PM:              62aee38098ef0d84345a.js   12.6 KiB       4  pages/articles/index
11:13:38 PM:              62ca27f64ea11dbd388e.js   12.7 KiB      12  pages/literature-poetry/index
11:13:38 PM:              68570d73d3cc0726e0e1.js   11.8 KiB      33  pages/photography/posts/search/page/_pageNum
11:13:38 PM:              695064e2d97bbf093667.js   12.6 KiB      24  pages/music/index
11:13:38 PM:              69c29103b8a3228e38b8.js    113 KiB       1  app
11:13:38 PM:              6bee9e9833e8dfea8b0e.js   11.9 KiB      39  pages/regional/posts/search/page/_pageNum
11:13:38 PM:              6d59a37cdf09bf0bed9c.js    194 KiB       2  commons.app
11:13:38 PM:              6e556836004cc7d77285.js   65.6 KiB      46  vendors.pages/contact
11:13:38 PM:              715e27e7e7ebe62980e4.js   2.08 KiB      43  pages/termsconditions
11:13:38 PM:              8e3688fb9c457755f170.js   6.11 KiB      14  pages/literature-poetry/posts/overview/index
11:13:38 PM:              9b48190ec2f9aad78cda.js   3.09 KiB      42  pages/resume
11:13:42 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
11:13:38 PM:              9cd775f3c147971c7a28.js   12.6 KiB      30  pages/photography/index
11:13:38 PM:                             LICENSES  582 bytes          
11:13:43 PM: Shutting down logging, 85 messages pending

相比之下,当我 运行 npm run generate 在本地时,所有对 Storyblok 的请求(使用 Axios)都会创建所有预期的路线,没有任何错误或警告。

我没有共享存储库,因为它是一个私有存储库并且内部有令牌,但如果需要任何信息,请告诉我。 如果有任何想法可以尝试修复它,请赐教并感谢您的宝贵时间。

我找到了解决方案,它与具体的 Nuxt、Storyblok 或其他任何东西都没有任何关系,这基本上是一个拼写错误。

我开始清理我在不同地方的潜在 console.log(...) 的项目,我的想法是看看这样 Netlify 日志是否会给我更多的细节,因为它们不会被隐藏来自 console.logs.

清理和 git 推送之后,下一个部署确实在控制台中输出了更清晰的错误,这有助于我跟踪错误的位置。它位于 SectionImage SVG 组件中,基本上与 Nuxt 的 SVG 模块一起使用,我将 name 属性写为 Sectionimage。所以修复后一切正常!





(Nuxt - Vue - Vuetify 和 Storyblok(第一次使用它)摇滚!:D)