Firebase错误:部署数据库规则时出现意外错误

ilmyapht  于 2023-03-31  发布在  其他
关注(0)|答案(3)|浏览(207)

我正在尝试将我的angular应用部署到firebase,我尝试了各种教程中的所有方法来初始化firebase,选择托管,然后在firebase上部署我的应用。但我总是得到一个错误:

我不知道出什么事了。
这是我的firebase-debug.log的外观

[debug] [2020-03-26T10:42:00.096Z] ----------------------------------------------------------------------
[debug] [2020-03-26T10:42:00.098Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\pulki\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy
[debug] [2020-03-26T10:42:00.098Z] CLI Version:   7.16.1
[debug] [2020-03-26T10:42:00.098Z] Platform:      win32
[debug] [2020-03-26T10:42:00.098Z] Node Version:  v10.16.3
[debug] [2020-03-26T10:42:00.099Z] Time:          Thu Mar 26 2020 16:12:00 GMT+0530 (India Standard Time)
[debug] [2020-03-26T10:42:00.099Z] ----------------------------------------------------------------------
[debug] [2020-03-26T10:42:00.099Z] 
[debug] [2020-03-26T10:42:00.105Z] > 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"]
[debug] [2020-03-26T10:42:00.105Z] > authorizing via signed-in user
[debug] [2020-03-26T10:42:00.105Z] [iam] checking project frezzo-pul5 for permissions ["firebase.projects.get","firebasedatabase.instances.update","firebasehosting.sites.update"]
[debug] [2020-03-26T10:42:00.108Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-03-26T10:42:00.108Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[debug] [2020-03-26T10:42:00.624Z] <<< HTTP RESPONSE 200
[debug] [2020-03-26T10:42:00.630Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/frezzo-pul5:testIamPermissions  

[debug] [2020-03-26T10:42:02.770Z] <<< HTTP RESPONSE 200
[debug] [2020-03-26T10:42:02.772Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/frezzo-pul5  

[debug] [2020-03-26T10:42:03.760Z] <<< HTTP RESPONSE 200
[info] 
[info] === Deploying to 'frezzo-pul5'...
[info] 
[info] i  deploying database, hosting
[info] i  database: checking rules syntax...
[debug] [2020-03-26T10:42:03.764Z] >>> HTTP REQUEST PUT https://frezzo-pul5.firebaseio.com/.settings/rules.json?dryRun=true  
 {
    "rules": {
        ".read": true,
        ".write": true
    }
}
[debug] [2020-03-26T10:42:06.330Z] <<< HTTP RESPONSE 404
[debug] [2020-03-26T10:42:06.330Z] <<< HTTP RESPONSE BODY {
  "error" : "Firebase error. Please ensure that you spelled the name of your Firebase correctly"
}

[error] 
[error] Error: Unexpected error while deploying database rules.

我没有在我的firebase数据库上设置安全性。这是一个问题吗?
我也试过Firebase Serve在本地检查我的应用程序,效果很好。
感谢您的帮助!!

fhg3lkii

fhg3lkii1#

如果您在激活后停用了一个或多个函数,那么在第一次运行$ firebase init时,在尝试部署时会出现混乱。
例如,有时候实时数据库会自动停用,如果你不使用它们的话,你可以尝试重新启用它们以便部署;否则,你需要使用不同的选项重新运行init,并删除不使用的文件。

bwitn5fc

bwitn5fc2#

我安装了不同版本的firebase-tools(9.23.3我有6.something).它为我解决了这个问题.

iswrvxsc

iswrvxsc3#

尝试从控制台启动firebase数据库。在大多数情况下,firebase数据库没有在云上设置,因此控制台实用程序无法上传db规则,因此出现此错误。尝试使用以下命令:

firebase init database

以下更新将在控制台上进行:

=== Database Setup
i  database: ensuring required API firebasedatabase.googleapis.com is enabled...
⚠  database: missing required API firebasedatabase.googleapis.com. Enabling now...
✔  database: required API firebasedatabase.googleapis.com is enabled

? It seems like you haven’t initialized Realtime Database in your project yet. Do you want to set it up? Yes
? Please choose the location for your default Realtime Database instance: us-central1
✔ Creating your default Realtime Database instance: ********-default-rtdb

这样,您的数据库部署错误可能会得到解决。

相关问题