部署NextJs至Firebase App Hosting时Step #2出现报错
Next.js 部署 Firebase App Hosting 构建失败问题
我有一个 Next.js 应用,尝试首次部署至 Firebase App Hosting。已按照官方文档配置后端并集成 GitHub 开启自动部署,但所有构建均失败,报错信息如下:
2024-11-06 16:54:37.443 BRT Step #2: Installing nextjs adaptor 14.0.9 2024-11-06 16:54:41.870 BRT Step #2: === Node.js - Yarn (google.nodejs.yarn@2.1.0) === 2024-11-06 16:54:41.871 BRT Step #2: ***** CACHE MISS: "yarn_engine" 2024-11-06 16:54:41.871 BRT Step #2: Installing Yarn v4.5.0 2024-11-06 16:54:41.872 BRT Step #2: 2024/11/06 19:54:41 [DEBUG] GET https://repo.yarnpkg.com/4.5.0/packages/yarnpkg-cli/bin/yarn.js 2024-11-06 16:54:42.051 BRT Step #2: Setting environment variable PATH=/layers/google.nodejs.yarn/yarn_engine/bin:/layers/google.nodejs.runtime/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 2024-11-06 16:54:42.070 BRT Step #2: ***** CACHE MISS: "yarn_modules" 2024-11-06 16:54:42.072 BRT Step #2: -------------------------------------------------------------------------------- 2024-11-06 16:54:42.072 BRT Step #2: Running "yarn install --non-interactive --prefer-offline --modules-folder=/layers/google.nodejs.yarn/yarn_modules/node_modules --frozen-lockfile --production=false (PATH=/layers/google.nodejs.yarn/yarn_engine/bin:/layers/google.nodejs.runtime/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/layers/google.nodejs.yarn/yarn_modules/node_modules/.bin)" 2024-11-06 16:54:42.454 BRT Step #2: Unknown Syntax Error: Invalid option name ("--modules-folder=/layers/google.nodejs.yarn/yarn_modules/node_modules"). 2024-11-06 16:54:42.454 BRT Step #2: 2024-11-06 16:54:42.454 BRT Step #2: $ yarn install [--json] [--immutable] [--immutable-cache] [--refresh-lockfile] [--check-cache] [--check-resolutions] [--inline-builds] [--mode #0] 2024-11-06 16:54:42.489 BRT Step #2: Done "yarn install --non-interactive --prefer-offline --modules-fo..." (418.675079ms) 2024-11-06 16:54:42.489 BRT Step #2: -------------------------------------------------------------------------------- 2024-11-06 16:54:42.489 BRT Step #2: failed to build: (error ID: 7590068d): 2024-11-06 16:54:42.489 BRT Step #2: Unknown Syntax Error: Invalid option name ("--modules-folder=/layers/google.nodejs.yarn/yarn_modules/node_modules"). 2024-11-06 16:54:42.489 BRT Step #2: 2024-11-06 16:54:42.489 BRT Step #2: $ yarn install [--json] [--immutable] [--immutable-cache] [--refresh-lockfile] [--check-cache] [--check-resolutions] [--inline-builds] [--mode #0] 2024-11-06 16:54:42.491 BRT Step #2: Timer: Builder ran for 7.35782479s and ended at 2024-11-06T19:54:42Z 2024-11-06 16:54:42.491 BRT Step #2: ERROR: failed to build: exit status 1 2024-11-06 16:54:43.694 BRT Step #2: ERROR: failed to build: executing lifecycle: failed with status code: 51
该错误未出现在 Google Cloud 故障排查文档中,Gemini 也无法解释原因。以下是相关配置文件:
next.config.mjs
import bundleAnalyzer from '@next/bundle-analyzer'; const withBundleAnalyzer = bundleAnalyzer({ enabled: process.env.ANALYZE === 'true', }); export default withBundleAnalyzer({ reactStrictMode: false, eslint: { ignoreDuringBuilds: true, }, experimental: { optimizePackageImports: ['@mantine/core', '@mantine/hooks'], serverActions: true, output: "export", }, });
firebase.json
{ "emulators": { "auth": { "port": 9099 }, "functions": { "port": 5001 }, "firestore": { "port": 3001 }, "ui": { "enabled": true }, "singleProjectMode": true }, "functions": [ { "source": "functions", "codebase": "default", "ignore": [ "venv", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local" ] } ], "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "hosting": { "source": ".", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "frameworksBackend": { "region": "us-central1" } } }
内容的提问来源于stack exchange,提问作者mdeotti
相关产品推荐
相关产品推荐

