使用 Github 将 Nuxt 静态站点部署到 Netlify

Issue deploying Nuxt static site to Netlify using Github

我在使用 Github 将我的 Nuxt 静态站点(使用 Bootstrap Vue 构建并使用 Wordpress Rest API)部署到 Netlify 时遇到问题。当我手动部署它时,它按预期工作。但是当我使用 Github 时,它会为大多数页面和那些没有出现该错误的页面提供“页面未找到消息”,它不会提供所有页面内容。

我遵循了静态生成站点的 Nuxt 配置:[https://nuxtjs.org/deployments/netlify/#for-a-statically-generated-site][1]。我也尝试更改 NODE_VERSION 环境变量但没有成功。有没有人有解决这个问题的建议?

这是来自 Netlify 的部署日志

11:26:18 AM: build-image version: a6bb34428a07e7de82f4df5dfe1843fbde91f670 (focal)
11:26:18 AM: build-image tag: v4.5.1
11:26:18 AM: buildbot version: 5284b4d1b8b4cf691b29019968d8e4eb3089acdd
11:26:18 AM: Fetching cached dependencies
11:26:18 AM: Failed to fetch cache, continuing with build
11:26:18 AM: Starting to prepare the repo for build
11:26:19 AM: No cached dependencies found. Cloning fresh repo
11:26:19 AM: git clone https://github.com/DianaNilsson/devmore-headless-wp
11:26:19 AM: Preparing Git Reference refs/heads/master
11:26:20 AM: Parsing package.json dependencies
11:26:21 AM: Starting build script
11:26:21 AM: Installing dependencies
11:26:21 AM: Python version set to 2.7
11:26:22 AM: v16.13.1 is already installed.
11:26:23 AM: Now using node v16.13.1 (npm v8.1.2)
11:26:23 AM: Started restoring cached build plugins
11:26:23 AM: Finished restoring cached build plugins
11:26:23 AM: Attempting ruby version 2.7.2, read from environment
11:26:25 AM: Using ruby version 2.7.2
11:26:25 AM: Using PHP version 8.0
11:26:25 AM: Started restoring cached node modules
11:26:25 AM: Finished restoring cached node modules
11:26:26 AM: Installing NPM modules using NPM version 8.1.2
11:26:29 AM: npm WARN old lockfile
11:26:29 AM: npm WARN old lockfile The package-lock.json file was created with an old version of npm,
11:26:29 AM: npm WARN old lockfile so supplemental metadata must be fetched from the registry.
11:26:29 AM: npm WARN old lockfile
11:26:29 AM: npm WARN old lockfile This is a one-time fix-up, please be patient...
11:26:29 AM: npm WARN old lockfile
11:26:52 AM: npm WARN deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
11:26:53 AM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
11:26:53 AM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
11:27:00 AM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
11:27:08 AM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
11:27:10 AM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
11:27:11 AM: npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
11:27:14 AM: npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
11:27:17 AM: added 1229 packages, and audited 1230 packages in 50s
11:27:17 AM: 104 packages are looking for funding
11:27:17 AM:   run `npm fund` for details
11:27:17 AM: 15 vulnerabilities (7 moderate, 8 high)
11:27:17 AM: To address issues that do not require attention, run:
11:27:17 AM:   npm audit fix
11:27:17 AM: To address all issues (including breaking changes), run:
11:27:17 AM:   npm audit fix --force
11:27:17 AM: Run `npm audit` for details.
11:27:17 AM: NPM modules installed
11:27:18 AM: Started restoring cached go cache
11:27:18 AM: Finished restoring cached go cache
11:27:18 AM: go version go1.16.5 linux/amd64
11:27:18 AM: go version go1.16.5 linux/amd64
11:27:18 AM: Installing missing commands
11:27:18 AM: Verify run directory
11:27:20 AM: ​
11:27:20 AM: ────────────────────────────────────────────────────────────────
11:27:20 AM:   Netlify Build                                                 
11:27:20 AM: ────────────────────────────────────────────────────────────────
11:27:20 AM: ​
11:27:20 AM: ❯ Version
11:27:20 AM:   @netlify/build 20.3.1
11:27:20 AM: ​
11:27:20 AM: ❯ Flags
11:27:20 AM:   baseRelDir: true
11:27:20 AM:   buildId: 61b9c2c801d254a8c2bc2a45
11:27:20 AM:   deployId: 61b9c2c801d254a8c2bc2a47
11:27:20 AM: ​
11:27:20 AM: ❯ Current directory
11:27:20 AM:   /opt/build/repo
11:27:20 AM: ​
11:27:20 AM: ❯ Config file
11:27:20 AM:   No config file was defined: using default values.
11:27:20 AM: ​
11:27:20 AM: ❯ Context
11:27:20 AM:   production
11:27:20 AM: ​
11:27:20 AM: ────────────────────────────────────────────────────────────────
11:27:20 AM:   1. Build command from Netlify app                             
11:27:20 AM: ────────────────────────────────────────────────────────────────
11:27:20 AM: ​
11:27:20 AM: $ npm run generate
11:27:21 AM: > devmore-headless-wp@1.0.0 generate
11:27:21 AM: > nuxt generate
11:27:42 AM: [error] [BABEL] Note: The code generator has deoptimised the styling of /opt/build/repo/node_modules/bootstrap-vue/src/icons/icons.js as it exceeds the max of 500KB.
11:28:12 AM: [error]  /kontakt
11:28:12 AM: 
11:28:12 AM: TypeError: Cannot read properties of undefined (reading 'title')
11:28:12 AM:     at a.render (pages/kontakt.vue?a191:1:0)
11:28:12 AM:     at a.t._render (/opt/build/repo/node_modules/vue/dist/vue.runtime.common.prod.js:6:35346)
11:28:12 AM:     at /opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70854
11:28:12 AM:     at eo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67418)
11:28:12 AM:     at oo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70830)
11:28:12 AM:     at no (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70461)
11:28:12 AM:     at to (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67708)
11:28:12 AM:     at /opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70928
11:28:12 AM:     at eo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67418)
11:28:12 AM:     at oo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70830)
11:28:12 AM:     at no (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70461)
11:28:12 AM:     at to (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67708)
11:28:12 AM:     at /opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70928
11:28:12 AM:     at eo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67418)
11:28:12 AM:     at oo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70830)
11:28:12 AM:     at no (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70461)
11:28:12 AM: [error]  /om-oss
11:28:12 AM: 
11:28:12 AM: TypeError: Cannot read properties of undefined (reading 'title')
11:28:12 AM:     at a.render (pages/om-oss.vue?bc3a:1:0)
11:28:12 AM:     at a.t._render (/opt/build/repo/node_modules/vue/dist/vue.runtime.common.prod.js:6:35346)
11:28:12 AM:     at /opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70854
11:28:12 AM:     at eo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67418)
11:28:12 AM:     at oo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70830)
11:28:12 AM:     at no (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70461)
11:28:12 AM:     at to (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67708)
11:28:12 AM:     at /opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70928
11:28:12 AM:     at eo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67418)
11:28:12 AM:     at oo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70830)
11:28:12 AM:     at no (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70461)
11:28:12 AM:     at to (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67708)
11:28:12 AM:     at /opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70928
11:28:12 AM:     at eo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:67418)
11:28:12 AM:     at oo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70830)
11:28:12 AM:     at no (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70461)
11:28:12 AM: [error]  /
11:28:12 AM: 
11:28:12 AM: Error: connect ECONNREFUSED 127.0.0.1:80
11:28:12 AM:     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
11:28:12 AM: [error] connect ECONNREFUSED 127.0.0.1:80
11:28:12 AM:   at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
11:28:13 AM: ​
11:28:13 AM: (build.command completed in 52.6s)
11:28:13 AM: ​
11:28:13 AM: ────────────────────────────────────────────────────────────────
11:28:13 AM:   2. Deploy site                                                
11:28:13 AM: ────────────────────────────────────────────────────────────────
11:28:13 AM: Starting to deploy site from 'dist'
11:28:13 AM: Creating deploy tree 
11:28:13 AM: ​
11:28:13 AM: Creating deploy upload records
11:28:13 AM: 3 new files to upload
11:28:13 AM: 0 new functions to upload
11:28:13 AM: Site deploy was successfully initiated
11:28:13 AM: ​
11:28:13 AM: (Deploy site completed in 663ms)
11:28:13 AM: ​
11:28:13 AM: ────────────────────────────────────────────────────────────────
11:28:13 AM:   Netlify Build Complete                                        
11:28:13 AM: ────────────────────────────────────────────────────────────────
11:28:13 AM: ​
11:28:13 AM: (Netlify Build completed in 53.5s)
11:28:14 AM: Starting post processing
11:28:14 AM: Post processing - HTML
11:28:14 AM: Caching artifacts
11:28:14 AM: Started saving node modules
11:28:14 AM: Finished saving node modules
11:28:14 AM: Started saving build plugins
11:28:14 AM: Finished saving build plugins
11:28:14 AM: Started saving pip cache
11:28:14 AM: Finished saving pip cache
11:28:14 AM: Started saving emacs cask dependencies
11:28:14 AM: Finished saving emacs cask dependencies
11:28:14 AM: Started saving maven dependencies
11:28:14 AM: Finished saving maven dependencies
11:28:14 AM: Started saving boot dependencies
11:28:14 AM: Finished saving boot dependencies
11:28:14 AM: Started saving rust rustup cache
11:28:14 AM: Finished saving rust rustup cache
11:28:14 AM: Post processing - header rules
11:28:14 AM: Started saving go dependencies
11:28:14 AM: Finished saving go dependencies
11:28:14 AM: Post processing - redirect rules
11:28:14 AM: Post processing done
11:28:14 AM: Site is live ✨
11:28:16 AM: Build script success
11:28:38 AM: Finished processing build request in 2m19.82235889s```

问题是您尝试在 Netlify 上使用本地服务器进行部署。您还需要部署后端。