Search code examples
node.jsfirebasegoogle-cloud-pubsub

how to add new firebase emulators to my existing project?


so I already have some firebase emulators running on my project (auth, functions and firestore emulators).

if I run firebase emulators:start then I will have this 2 messages in my terminal

i emulators: Starting emulators: auth, functions, firestore

⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, hosting, pubsub

now I want to add pubsub emulator to my current project, how to do that? I use NodeJS


Solution

  • just open your firebase.json file and then you can add or remove the value in the json file as you need

    firebase.json file is located in the same hierarchy as your functions folder (outside your functions folder)

    see the documentation in here

    "emulators": {
        "firestore": {
          "port": "8080"
        },
        "ui": {
          "enabled": true,      
          "port": 4000         
        },
        "auth": {
          "port": "9099"
        },
        "functions": {
          "port": "5001"
        },
        "database": {
          "port": "9000"
        },
        "hosting": {
          "port": "5000"
        },
        "pubsub": {  // add this if you want to add pubsub emulator
          "port": "8085"
        }
      }
    

    the CLI will then automatically download the emulators after you run firebase emulators:start