Firebase托管具有动态内容的多个网站。在文件下面,我正在使用基于目标的主机到该站点之一。但是有些失败了。
将目标应用于网站的命令
目标:应用托管目标名称目标站点
部署命令
firebase部署-仅托管:目标名称
firebase.json
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "functions"
},
"hosting": {
"public": "public",
"target": "target-name",
"rewrites": [
{
"source": "/**",
"function": "function"
}
]
}
}
错误日志:
> [2019-08-02T08:02:33.699Z]
> ---------------------------------------------------------------------- [2019-08-02T08:02:33.703Z] Command:
> /home/johndoe/.nvm/v10.9.0/bin/node
> /home/johndoe/.nvm/v10.9.0/bin/firebase deploy --only
> hosting:target-name --debug [2019-08-02T08:02:33.703Z] CLI Version:
> 6.4.0 [2019-08-02T08:02:33.703Z] Platform: linux [2019-08-02T08:02:33.703Z] Node Version: v10.9.0
> [2019-08-02T08:02:33.704Z] Time: Fri Aug 02 2019 13:32:33
> GMT+0530 (India Standard Time) [2019-08-02T08:02:33.704Z]
> ----------------------------------------------------------------------
>
> [2019-08-02T08:02:33.712Z] > 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"]
> [2019-08-02T08:02:33.713Z] > authorizing via signed-in user
> [2019-08-02T08:02:33.713Z] [iam] checking project first for
> permissions ["firebase.projects.get","firebasehosting.sites.update"]
> [2019-08-02T08:02:33.718Z] >>> HTTP REQUEST POST
> https://cloudresourcemanager.googleapis.com/v1/projects/first:testIamPermissions
> permissions=[firebase.projects.get, firebasehosting.sites.update]
> [2019-08-02T08:02:35.337Z] <<< HTTP RESPONSE 200
> content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
> Origin,Accept-Encoding, date=Fri, 02 Aug 2019 08:05:56 GMT,
> server=ESF, cache-control=private, x-xss-protection=0,
> x-frame-options=SAMEORIGIN, x-content-type-options=nosniff,
> server-timing=gfet4t7; dur=1407, alt-svc=quic=":443"; ma=2592000;
> v="46,43,39", accept-ranges=none, transfer-encoding=chunked
> [2019-08-02T08:02:35.340Z] >>> HTTP REQUEST GET
> https://firebase.googleapis.com/v1beta1/projects/first
> [2019-08-02T08:02:35.816Z] <<< HTTP RESPONSE 200
> content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
> Origin,Accept-Encoding, date=Fri, 02 Aug 2019 08:05:57 GMT,
> server=ESF, cache-control=private, x-xss-protection=0,
> x-frame-options=SAMEORIGIN, x-content-type-options=nosniff,
> alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none,
> transfer-encoding=chunked [2019-08-02T08:02:38.550Z] TypeError: Cannot
> read property 'deploys' of undefined
> at /home/prateekk/.nvm/v10.9.0/lib/node_modules/firebase-tools/lib/deploy/index.js:88:36
> at process._tickCallback (internal/process/next_tick.js:68:7)
家教
答案 0 :(得分:0)
经过大量挖掘。终于对我有用。下面是我的firebase.json结构。
使用用于托管的数组结构并运行“ f irebase初始托管”-重置firebase.json
firebase.json
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "functions"
},
"hosting": [{
"public": "public",
"target": "target-name",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/**",
"function": "function"
}
]
}]
}