我正在尝试使用 Firestore、Functions、Storage 和 Hosting 为生产和开发环境设置 2 个全新的 Firebase 项目。我首先删除对旧 firebase 项目的引用: both firebase.json
& .firebaserc
。然后我跑去$ firebase init
使用test
Firebase 项目设置 Hosting、Functions、Storage 和 Firestore 。然后我设置 Firebase 别名以$ firebase use --add
在一个 React.js 项目中的两个项目之间切换。我使用 npm 构建并尝试使用: 进行部署$ firebase deploy --project:test
,但主机不断尝试使用相同的最后一个文件并失败:Error: Task 5fcd... failed: retries exhausted after 6 attempts.
。
我已经看到了一些与服务器暂时关闭相关的 Stackoverflow 答案,但我没有看到他们这边的任何服务器问题(https://status.firebase.google.com/),而且这种情况以前一直存在。在我参与的另一个项目中,我试图在同一个 Firebase 项目上部署到 2 个托管目标,但是一个失败了,另一个工作正常,我遇到了同样的错误(我从来没有找到另一个解决方案比不使用多个目标。)
我还可以测试什么才能使其正常工作?它在我的 React.js 代码库中吗?(我最近部署到我过去的项目中)也许这与我的 Firebase 设置过程有关?或者仍然与旧的 Firebase 项目有联系?我不知道下一步该看什么来解决这个问题。任何方向都会很棒,谢谢!
Ps:可能无法连接的奇怪之处在于,如果我只运行$ firebase deploy
,它不会部署 firebaserc 中定义的默认测试环境,而是实时测试环境?
.firebaserc:
{
"projects": {
"default": "test-app-tech",
"test": "test-app-tech",
"live": "live-app-tech"
}
}
firebase.json:
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": "npm --prefix \"$RESOURCE_DIR\" run build"
},
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"storage": {
"rules": "storage.rules"
}
}
完整的控制台日志:( 不确定比控制台更长的日志文件在哪里)
=== Deploying to 'test-app-tech'...
i deploying storage, firestore, functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions@ build C:\Users\me\Documents\GitHub\react.app.tech\functions
> tsc
+ functions: Finished running predeploy script.
i firebase.storage: checking storage.rules for compilation errors...
+ firebase.storage: rules file storage.rules compiled successfully
i firestore: reading indexes from firestore.indexes.json...
i cloud.firestore: checking firestore.rules for compilation errors...
+ cloud.firestore: rules file firestore.rules compiled successfully
i functions: ensuring necessary APIs are enabled...
+ functions: all necessary APIs are enabled
i storage: latest version of storage.rules already up to date, skipping upload...
i firestore: uploading rules firestore.rules...
+ firestore: deployed indexes in firestore.indexes.json successfully
i functions: preparing functions directory for uploading...
i functions: packaged functions (80.39 KB) for uploading
+ functions: functions folder uploaded successfully
i hosting[test-app-tech]: beginning deploy...
i hosting[test-app-tech]: found 32 files in build
⠸ hosting: uploading new files [0/1] (0%)
Error: Task 5fcd5c559ded0c02b3ed7840ca3ee77e95b798730af98d9f18bc627ac898071e failed: retries exhausted after 6 attempts