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

部署Firebase云函数时npm报错:missing script: lint

Fixing "npm ERR! missing script: lint" in Firebase Functions Predeploy

Hey there, let's get this sorted out quickly! The error you're hitting is straightforward: your Firebase Functions project's package.json doesn't have a lint script defined, but Firebase's predeploy process is trying to run it via the command npm --prefix "$RESOURCE_DIR" run lint. That's why you're seeing the non-zero exit code error stopping your deploy.

Here's exactly what you need to do:

  1. Open your package.json file (it lives in your functions directory). You mentioned your scripts section currently looks like this:

    "scripts": { "serve": "firebase serve --only functions" }
    
  2. Add the lint script to the scripts object. You have two solid options here:

    • Option 1: Set up proper linting (recommended for long-term)
      First, install ESLint (the most widely used linting tool for JavaScript/TypeScript projects) in your functions directory:

      cd functions
      npm install eslint --save-dev
      

      Then update your package.json scripts to include the lint command:

      "scripts": {
        "serve": "firebase serve --only functions",
        "lint": "eslint ."
      }
      

      This will run ESLint across all your function files to catch code quality issues, syntax errors, and style inconsistencies.

    • Option 2: Temporarily bypass linting (quick fix only)
      If you just need to push your deploy through right now, you can add a dummy lint script that does nothing:

      "scripts": {
        "serve": "firebase serve --only functions",
        "lint": "echo 'Skipping linting temporarily'"
      }
      

      Heads up: This skips important code checks, so don't rely on this for production projects.

  3. Test the script first to make sure it works before redeploying:

    npm --prefix "$RESOURCE_DIR" run lint
    

    If you set up ESLint, it will output any linting errors/warnings. If you used the dummy script, it should just print your message without errors.

  4. Redeploy your functions – the predeploy error should now be resolved.

A quick note on why this happens:

Firebase's default predeploy configuration for Cloud Functions includes a lint check step. It expects your package.json to have a lint script defined, so when it can't find one, it throws the "missing script: lint" error and halts the deploy process.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 03:23:34