0
0
FirebaseHow-ToBeginner Ā· 3 min read

How to Start Firebase Emulator: Simple Steps to Run Locally

To start the Firebase Emulator, run firebase emulators:start in your project directory after installing the Firebase CLI. This command launches local emulators for services like Firestore, Authentication, and Functions for safe testing.
šŸ“

Syntax

The basic command to start the Firebase Emulator Suite is firebase emulators:start. You can add flags to specify which emulators to run or to use a specific configuration file.

  • firebase emulators:start: Starts all emulators defined in your firebase.json.
  • --only <emulator1,emulator2>: Runs only specified emulators, e.g., --only firestore,auth.
  • --import <path>: Imports saved emulator data from a folder.
  • --export-on-exit <path>: Saves emulator data on exit to a folder.
bash
firebase emulators:start [--only <emulator1,emulator2>] [--import <path>] [--export-on-exit <path>]
šŸ’»

Example

This example shows how to start the Firebase Emulator Suite with Firestore and Authentication emulators only. It assumes you have Firebase CLI installed and a firebase.json configured.

bash
firebase emulators:start --only firestore,auth
Output
āœ” emulators: Starting emulators: firestore, auth i firestore: Firestore Emulator logging to firestore-debug.log āœ” firestore: Firestore Emulator started at http://localhost:8080 i auth: Authentication Emulator logging to auth-debug.log āœ” auth: Authentication Emulator started at http://localhost:9099 āœ” All emulators started, it is now safe to connect your app.
āš ļø

Common Pitfalls

Some common mistakes when starting Firebase emulators include:

  • Not installing the Firebase CLI globally with npm install -g firebase-tools.
  • Running the command outside a Firebase project folder without firebase.json.
  • Forgetting to specify which emulators to start if you only want some.
  • Not configuring ports properly, causing conflicts with other services.

Always check your firebase.json to ensure emulators are configured correctly.

bash
Wrong: firebase start
Right: firebase emulators:start
šŸ“Š

Quick Reference

CommandDescription
firebase emulators:startStart all configured emulators
firebase emulators:start --only firestore,authStart only Firestore and Authentication emulators
firebase emulators:start --import ./saved-dataStart emulators with imported data
firebase emulators:start --export-on-exit ./saved-dataSave emulator data on exit
āœ…

Key Takeaways

Run 'firebase emulators:start' inside your Firebase project folder to launch emulators.
Use '--only' flag to start specific emulators like Firestore or Authentication.
Ensure Firebase CLI is installed globally before running emulator commands.
Check your 'firebase.json' to configure which emulators to run and their ports.
Avoid running commands outside a Firebase project directory to prevent errors.