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

Firebase Functions部署失败:提示缺少build脚本

Fixing the "missing script: build" Error in Firebase Functions Deployment

Hey there! I’ve run into this exact issue before when getting started with Firebase Functions, so let’s walk through how to fix it step by step.

What’s causing this error?

The error means your Firebase Functions project’s package.json file doesn’t have a build script defined in its scripts section. Firebase looks for this script during deployment to prepare your code for production—most commonly, compiling TypeScript to JavaScript if you’re using TypeScript, which matches the tutorial you’re following.

How to fix it:

  1. Navigate to your Functions directory
    In your project root, head to the functions folder—this is where your package.json file lives.

  2. Open the package.json file
    Look for the "scripts" object. It might look like this if you’re missing the build script:

    "scripts": {
      "serve": "firebase emulators:start --only functions",
      "shell": "firebase functions:shell",
      "start": "npm run shell",
      "deploy": "firebase deploy --only functions",
      "logs": "firebase functions:log"
    }
    
  3. Add the build script
    Since the tutorial uses TypeScript, add this line inside the scripts object—it tells npm to run the TypeScript compiler to convert your .ts files to runnable .js code:

    "build": "tsc"
    

    Your updated scripts section should look like this:

    "scripts": {
      "build": "tsc",
      "serve": "firebase emulators:start --only functions",
      "shell": "firebase functions:shell",
      "start": "npm run shell",
      "deploy": "firebase deploy --only functions",
      "logs": "firebase functions:log"
    }
    

    If you’re using plain JavaScript (unlikely for this tutorial), you can add a dummy build script if Firebase still expects it:

    "build": "echo 'No build required for JavaScript'"
    
  4. Save the file and re-run deployment
    Run firebase deploy --only functions again, and the error should be resolved.

Quick troubleshooting if you’re still stuck:

  • Did you initialize your Functions project with TypeScript? If not, re-run firebase init functions and select TypeScript when prompted to set up the necessary tooling.
  • Double-check the tutorial’s sample package.json—you might have missed copying the build script from the provided example.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 07:59:06