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

部署Firebase Functions时如何关闭安装与构建流程?

彻底关闭Firebase Functions部署时的npm install与自动构建
  • 指定预打包代码目录
    在项目根目录的firebase.json中,修改functions配置的source字段,指向你存放预打包完成的函数代码目录(比如./dist/functions)。Firebase只会上传该目录内的文件,不会处理未打包的源码。

    示例配置:

    {
      "functions": {
        "source": "./dist/functions",
        "ignore": [
          ".git/**",
          "firebase-debug.log",
          "*.log"
        ]
      }
    }
    
  • 禁用预部署构建脚本
    清空firebase.json中functions的predeploy配置,避免本地或云端触发自动构建:

    {
      "functions": {
        "source": "./dist/functions",
        "predeploy": [],
        "ignore": [".git/**", "*.log"]
      }
    }
    
  • 跳过云端npm install
    部署时添加--no-install-deps参数,强制Firebase云端跳过npm install流程,直接使用你预打包好的依赖文件:

    firebase deploy --only functions --no-install-deps
    
  • 额外注意
    确保预打包目录下的package.json中没有build脚本(或已重命名为你自定义的如bundle),同时目录内包含所有运行所需文件:编译后的函数代码、预安装好的node_modules、配置正确的package.json。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 13:25:08