如何将新的 firebase 模拟器添加到我现有的项目中?

how to add new firebase emulators to my existing project?

所以我已经在我的项目中安装了一些 firebase 模拟器 运行(auth、函数和 firestore 模拟器)。

如果我 运行 firebase emulators:start 那么我将在我的终端中收到这 2 条消息

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

现在我想将发布订阅模拟器添加到我当前的项目中,该怎么做?我使用 NodeJS

只需打开 firebase.json 文件,然后您可以根据需要在 json 文件中添加或删除值

firebase.json 文件与您的 functions 文件夹处于同一层次结构

查看文档in here

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

CLI 将在您 运行 firebase emulators:start

之后下载模拟器