部署NextJs应用至Firebase Hosting时遭遇未知错误求助
Next.js 部署 Firebase Hosting 失败问题排查
问题描述
尝试将 Next.js 应用部署到 Firebase Hosting,执行firebase deploy或firebase deploy --only hosting均失败。已提前执行firebase experiments:enable webframeworks再初始化 hosting,但 CLI、GitHub CI/CD 部署都无法完成,模拟器也无法打开。
系统环境
- Ubuntu 22.10
- Node.js 16.19.1,npm 8.19.3(通过 NVM 管理,已尝试过其他版本)
- Firebase-tools 11.23.1(通过官方自动安装脚本下载)
- Next.js 13.1.6
错误日志
firebase-debug.log 错误信息
[debug] [2023-02-17T21:36:36.278Z] Error: Command failed: npm i --omit dev --no-audit at checkExecSyncError (node:child_process:828:11) at Object.execSync (node:child_process:899:15) at execSync (pkg/prelude/bootstrap.js:2115:30) at prepareFrameworks (/home/rafael/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/frameworks/index.js:371:42) at async deploy (/home/rafael/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:53:13) [error] [error] Error: An unexpected error has occurred.
npm 日志信息
392 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin 392 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any 392 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux 392 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64 393 verbose stack Error: inotify@1.4.6 install: `node-gyp rebuild` 393 verbose stack spawn ENOENT 393 verbose stack at ChildProcess.<anonymous> (/snapshot/firepit/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18) 393 verbose stack at ChildProcess.emit (node:events:527:28) 393 verbose stack at maybeClose (node:internal/child_process:1092:16) 393 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) 394 verbose pkgid inotify@1.4.6 395 verbose cwd /home/rafael/dev/protea/web/.firebase/protea-technology-services/functions 396 verbose Linux 5.19.0-31-generic 397 verbose argv "/usr/local/bin/firebase" "/snapshot/firepit/node_modules/npm/bin/npm-cli" "--script-shell=/home/rafael/.cache/firebase/runtime/shell" "--globalconfig=/home/rafael/.cache/firebase/runtime/npmrc" "--userconfig=/home/rafael/.cache/firebase/runtime/npmrc" "--scripts-prepend-node-path=auto" "i" "--omit" "dev" "--no-audit" 398 verbose node v16.16.0 399 verbose npm v6.14.18 400 error code ELIFECYCLE 401 error syscall spawn 402 error file /home/rafael/.cache/firebase/runtime/shell 403 error errno ENOENT 404 error inotify@1.4.6 install: `node-gyp rebuild` 404 error spawn ENOENT 405 error Failed at the inotify@1.4.6 install script. 405 error This is probably not a problem with npm. There is likely additional logging output above. 406 verbose exit [ 1, true ]
firebase.json 配置片段
"hosting": { "source": ".", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ] }, "functions": [ { "source": "functions", "codebase": "default", "ignore": [ "node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log" ], "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint", "npm --prefix \"$RESOURCE_DIR\" run build" ] } ]
内容的提问来源于stack exchange,提问作者Rafael Zasas
相关产品推荐
相关产品推荐

