模拟器无法识别构建器(运行全部时),“仅功能、存储”上没有模拟器。每个都很好用

问题描述 投票:0回答:1

我有一个奇怪的情况。我可以使用命令单独运行我的函数模拟器

firebase --debug emulators:start --only functions

我可以使用以下命令运行存储模拟器:

firebase --debug emulators:start --only storage

但是当尝试将它们一起运行时,我收到错误:

firebase --debug emulators:start --only functions, storage
=>

[2024-02-08T21:09:44.860Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2024-02-08T21:09:44.862Z] > authorizing via signed-in user ([email protected])
i  emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}

Error: No emulators to start, run firebase init emulators to get started.

现在,我已经运行了 init 函数,这就是为什么我可以独立运行它们。

当尝试运行我设置的所有模拟器时,我遇到了以下情况

firebase --debug emulators:start
==>

[2024-02-08T21:06:00.794Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2024-02-08T21:06:00.796Z] > authorizing via signed-in user ([email protected])
[2024-02-08T21:06:00.916Z] java version "21.0.2" 2024-01-16 LTS

[2024-02-08T21:06:00.917Z] Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)

[2024-02-08T21:06:00.970Z] Parsed Java major version: 21
i  emulators: Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage, eventarc {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage, eventarc"}}
[2024-02-08T21:06:01.003Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2024-02-08T21:06:01.004Z] [auth] Authentication Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2024-02-08T21:06:01.004Z] [firestore] Firestore Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2024-02-08T21:06:01.005Z] [firestore.websocket] websocket server for firestore only supports listening on one address (127.0.0.1). Not listening on ::1      
[2024-02-08T21:06:01.006Z] [database] Database Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2024-02-08T21:06:01.006Z] [hosting] Hosting Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2024-02-08T21:06:01.007Z] [pubsub] Pub/Sub Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2024-02-08T21:06:01.007Z] [storage] Storage Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2024-02-08T21:06:01.008Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"auth":[{"address":"127.0.0.1","family":"IPv4","port":9099}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8081}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"database":[{"address":"127.0.0.1","family":"IPv4","port":9000}],"hosting":[{"address":"127.0.0.1","family":"IPv4","port":5000}],"pubsub":[{"address":"127.0.0.1","family":"IPv4","port":8085}],"storage":[{"address":"127.0.0.1","family":"IPv4","port":9199}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2024-02-08T21:06:01.023Z] [hub] writing locator at C:\Users\User\AppData\Local\Temp\hub-proj-a0c37.json
... REDACTED FOR SECURIY ...
   Thank you for trying our early preview of Angular support on Firebase Hosting.
   During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.

   File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md
   Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md

   We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X

i  emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
i  hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}

Error: @angular-devkit/build-angular:browser (app:build:development) is not a recognized builder. Please check your angular.json

很明显存在构建器问题,但没有在哪里说明适合 Ionic+Angular+Firebase 构建的构建器。这就是功能+存储停止工作的原因吗?

我的配置:

firebase.json:

{
  "hosting": [
    {
      "target": "app",
      "source": ".",
      "frameworksBackend": {}
    }
  ],
  "emulators": {
    "auth": {
      "port": 9099
    },
    "functions": {
      "port": 5001
    },
    "firestore": {
      "port": 8081
    },
    "hosting": {
      "port": 5000
    },
    "pubsub": {
      "port": 8085
    },
    "storage": {
      "port": 9199
    },
    "ui": {
      "enabled": true
    },
    "singleProjectMode": true,
    "database": {
      "port": 9000
    },
    "eventarc": {
      "port": 9299
    }
  },
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ],
      "predeploy": [
        "npm --prefix \"$RESOURCE_DIR\" run lint",
        "npm --prefix \"$RESOURCE_DIR\" run build"
      ]
    }
  ],
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "storage": {
    "rules": "storage.rules"
  }
}

主项目package.json:

{
  "name": projectionic",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "rm -rf ./dist && cp -r ../dist . && tsc",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint",
    "build:functions": "npm run --prefix functions build"
  },
  "private": true,
  "dependencies": {
    "@angular-builders/custom-webpack": "^17.0.0",
    "@angular/animations": "^17.0.2",
    "@angular/cdk": "^17.0.4",
    "@angular/common": "^17.0.2",
    "@angular/compiler": "^17.0.2",
    "@angular/core": "^17.0.2",
    "@angular/fire": "^17.0.0",
    "@angular/forms": "^17.0.2",
    "@angular/platform-browser": "^17.0.2",
    "@angular/platform-browser-dynamic": "^17.0.2",
    "@angular/router": "^17.0.2",
    "@capacitor/app": "5.0.6",
    "@capacitor/core": "5.5.1",
    "@capacitor/haptics": "5.0.6",
    "@capacitor/keyboard": "5.0.6",
    "@capacitor/status-bar": "5.0.6",
    "@ionic/angular": "^7.0.0",
    "@ngrx/operators": "^17.0.1",
    "@ngrx/signals": "^17.0.1",
    "buffer": "^6.0.3",
    "crypto-browserify": "^3.12.0",
    "ionicons": "^7.0.0",
    "rxjs": "~7.8.0",
    "stream-browserify": "^3.0.0",
    "tslib": "^2.3.0",
    "tslint": "^6.1.3",
    "zone.js": "~0.14.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.1.3",
    "@angular-eslint/builder": "17.1.1",
    "@angular-eslint/eslint-plugin": "17.1.1",
    "@angular-eslint/eslint-plugin-template": "17.1.1",
    "@angular-eslint/schematics": "17.1.1",
    "@angular-eslint/template-parser": "17.1.1",
    "@angular/cli": "17.1",
    "@angular/compiler-cli": "^17.0.2",
    "@angular/language-service": "^17.0.2",
    "@capacitor/cli": "5.5.1",
    "@ionic/angular-toolkit": "^9.0.0",
    "@ngrx/eslint-plugin": "^17.0.1",
    "@types/crypto-js": "^4.2.2",
    "@types/jasmine": "~5.1.0",
    "@typescript-eslint/eslint-plugin": "6.13.1",
    "@typescript-eslint/parser": "6.13.1",
    "eslint": "^8.56.0",
    "eslint-config-standard-with-typescript": "^43.0.1",
    "eslint-plugin-import": "^2.29.1",
    "eslint-plugin-jsdoc": "^48.0.2",
    "eslint-plugin-n": "^16.6.2",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "eslint-plugin-promise": "^6.1.1",
    "jasmine-core": "~5.1.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "ts-node": "^8.3.0",
    "typescript": "~5.2.2"
  },
  "description": "An Ionic project"
}

角度.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "app": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "www",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "assets"
              },
              {
                "glob": "**/*.svg",
                "input": "node_modules/ionicons/dist/ionicons/svg",
                "output": "./svg"
              }
            ],
            "styles": [
              "src/theme/variables.scss",
              "src/global.scss"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true
            },
            "ci": {
              "progress": false
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "app:build:production"
            },
            "development": {
              "buildTarget": "app:build:development"
            },
            "ci": {
              "progress": false
            }
          },
          "defaultConfiguration": "development"
        },
      }
    }
  },
  "cli": {
    "schematicCollections": [
      "@ionic/angular-toolkit"
    ],
    "analytics": false
  },
  "schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss"
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss"
    }
  }
}
angular firebase ionic-framework angularfire firebase-tools
1个回答
0
投票

解决了!!!

从模拟器堆栈中删除托管,

从 firebase.json 中删除了以下内容

    "hosting": [
        {
            "target": "app",
            "source": ".",
            "frameworksBackend": {}
        }
    ],
© www.soinside.com 2019 - 2024. All rights reserved.