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

Firebase CLI初始化Hosting时无法检测到NextJS框架

问题分析与解决办法

可能原因

  • 版本适配滞后:Firebase CLI 11.15.0对Next.js 12的自动检测逻辑不够完善,后续版本的CLI优化了框架识别能力,这属于版本间的兼容性问题,并非严格意义上的Bug。
  • 项目标识缺失:检查根目录是否存在next.config.js,以及package.json里是否配置了正确的build脚本(比如"build": "next build")——这两个文件/配置是CLI识别Next.js项目的关键依据。

临时解决方法

就算CLI没自动识别,手动配置也能正常部署:

  1. 执行firebase init hosting时,当要求指定构建目录,直接输入.next
  2. 初始化完成后,打开firebase.json调整hosting配置,针对SSR/ISR场景可添加后端区域配置,示例如下:
{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "us-central1"
    }
  }
}
  1. 最后执行firebase deploy即可完成部署。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 23:01:23