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

部署Firebase Hosting Functions遇Cloud Functions模拟器依赖缺失问题求助

Fix: The Cloud Functions emulator requires "firebase-admin" to be installed

Hey there, let's get this emulator issue sorted out—this is a common hiccup with straightforward fixes. Here's what to do step by step:

1. Double-check your working directory

The error explicitly says to run npm install in your functions subdirectory, not the root of your Firebase project. It’s super easy to accidentally run commands from the project root, which won’t install dependencies where the emulator needs them.

Open your terminal and navigate to the functions folder first:

cd functions

2. Clear corrupted dependencies and reinstall fresh

Sometimes outdated or corrupted node_modules folders/lock files can make packages show up in package.json but not actually be available to the emulator. Let’s wipe those and start over:

  • Delete the existing node_modules folder and lock file:
    # For macOS/Linux
    rm -rf node_modules package-lock.json
    
    # For Windows Command Prompt
    rmdir /s /q node_modules
    del package-lock.json
    
  • Reinstall all dependencies from scratch:
    npm install
    

3. Verify firebase-admin is properly installed

Once the install finishes, confirm the package is actually present:

  • Check if the node_modules/firebase-admin folder exists in your functions directory
  • Or run this command to list installed packages and confirm the version:
    npm list firebase-admin
    
    You should see a version number listed, not an error message.

4. Fix version mismatches (if issues persist)

Occasionally, incompatible versions of firebase-admin and firebase-functions can trigger this error. Try updating both to their latest compatible versions:

npm install firebase-admin@latest firebase-functions@latest

5. Restart the Firebase Emulator

Emulators sometimes cache old dependency states. After reinstalling, stop any running emulators and restart them to pick up the fresh dependencies:

firebase emulators:start

Extra tips if you’re still stuck:

  • If you use Yarn instead of npm, replace all npm install commands with yarn install
  • If you hit permission errors, avoid using sudo—use a Node version manager like nvm to handle permissions properly instead

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 07:24:43