You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将NextJS应用部署至Firebase Hosting时遇未知错误求助

部署NextJS+Firebase应用到Firebase Hosting时出现TypeError错误

我在部署一个基于NextJS和Firebase搭建的CRUD CMS到Firebase Hosting时,部署进程意外终止并报错。查日志后找到一个4月的GitHub Issue,指向Firebase CLI提取NextJS AppRouter路由信息的方式存在问题。尝试获取提议的修复方案未果,找到相关提交记录后更新Firebase CLI也没能解决问题。

这个应用功能简单,仅支持创建页面并在板块中插入图片和文本数据,未使用复杂功能。最初误以为是已知通用问题,未附上日志和配置文件,现补充如下信息:

环境信息

CLI Version:   11.27.0
Platform:      linux
Node Version:  v16.16.0

配置文件

package.json

{
  "name": "andreia-pinho",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "autoprefixer": "10.4.14",
    "bootstrap": "^5.3.2",
    "eslint": "8.44.0",
    "eslint-config-next": "13.4.10",
    "firebase": "^10.6.0",
    "firebase-tools": "^12.9.1",
    "next": "^13.4.19",
    "postcss": "8.4.26",
    "react": "18.2.0",
    "react-bootstrap": "^2.9.0",
    "react-dom": "18.2.0",
    "tailwindcss": "3.3.3"
  }
}

firebase.json

{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "europe-west1"
    }
  }
}

next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {
    output: 'export',
    images:{
      unoptimized: true
    }
}

module.exports = nextConfig

关键报错日志

[debug] [2023-11-16T23:16:30.885Z] TypeError: Cannot read properties of null (reading 'endsWith')
    at ɵcodegenPublicDirectory (/home/pbarbeira/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/frameworks/next/index.js:206:56)
    at async prepareFrameworks (/home/pbarbeira/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/frameworks/index.js:287:13)
    at async deploy (/home/pbarbeira/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:53:13)
[error] 
[error] Error: An unexpected error has occurred.

内容的提问来源于stack exchange,提问作者Pedro Barbeira

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 02:17:03