Firebase托管部署-无法读取未定义的属性“部署”

问题描述

我正在尝试将有角度的应用程序部署到Firebase。 Firebase已设置为托管多个站点

在Firebase中,项目名称为“ myapp-staging-84e3e”。 Firebase中有两个站点设置,分别是“ myapp-admin-staging”和“ myapp-staging-84e3e”。我正在尝试将此应用程序部署到“ myapp-admin-staging”。

当我尝试运行firebase deploy --only hosting:admin时,在firebase-debug.log中收到以下错误

[debug] [2020-08-24T15:19:23.581Z] TypeError: Cannot read property 'deploys' of undefined
    at /usr/local/lib/node_modules/firebase-tools/lib/deploy/index.js:84:36
    at processticksAndRejections (internal/process/task_queues.js:82:5)
[error] 
[error] Error: An unexpected error has occurred.

我必须正确设置某些东西,但我无法确定它是什么。我的.firebaserc文件看起来像这样;

    {
  "targets": {
    "myapp-staging-84e3e": {
      "hosting": {
        "admin": [
          "myapp-admin-staging"
        ]
      }
    }
  },"projects": {
    "default": "myapp-staging-84e3e"
  }
}

然后firebase.json文件看起来像这样;

{
  "hosting": {
    "public": "dist/MyApp-Admin","ignore": [
      "firebase.json","**/.*","**/node_modules/**"
    ],"rewrites": [
      {
        "source": "**","destination": "/index.html"
      }
    ]
  }
}

我要去哪里错了?

解决方法

您需要将"target": "admin"添加到您的firebase.json中,使其看起来像这样:

{
  "hosting": {
    "target": "admin",//added
    "public": "dist/MyApp-Admin","ignore": [
      "firebase.json","**/.*","**/node_modules/**"
    ],"rewrites": [
      {
        "source": "**","destination": "/index.html"
      }
    ]
  }
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...