我一直在尝试部署首次在项目中启用 firebase 功能时提供的默认测试功能,但收到了一个持续存在的错误。
const {onRequest} = require("firebase-functions/v2/https");
const logger = require("firebase-functions/logger");
exports.helloWorld = onRequest((request, response) => {
logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
下面是我安装的软件版本 节点:v18.17.0(即使我安装了最新版本的节点,错误仍然存在)
“firebase-admin”:“^11.8.0”, “firebase-functions”:“^4.3.1” “firebase-工具”:13.4.0 “npm”:10.4.0 “节点”:v18.17.0
这是我的 firebase.json 文件
{
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
//Even when I remove this part (predeploy) the error keeps showing
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
}
]
}
这是Package.json文件
{
"devDependencies": {
"eslint": "^8.57.0"
},
"dependencies": {
"firebase-functions": "^4.7.0"
},
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint ."
}
}
我正在尝试仅使用以下方式部署功能: firebase部署——仅功能
=== 部署到“复兴学院”...
i deploying functions
i functions: preparing codebase default for deployment
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
+ functions: required API cloudfunctions.googleapis.com is enabled
+ functions: required API cloudbuild.googleapis.com is enabled
+ artifactregistry: required API artifactregistry.googleapis.com is enabled
i functions: Loading and analyzing source code for codebase default to determine what to deploy
Serving at port 8844
i functions: preparing functions directory for uploading...
i functions: packaged C:\src\StudioProjects\Revival_academies\creche\functions (74.18 KB) for uploading
i functions: ensuring required API run.googleapis.com is enabled...
i functions: ensuring required API eventarc.googleapis.com is enabled...
i functions: ensuring required API pubsub.googleapis.com is enabled...
i functions: ensuring required API storage.googleapis.com is enabled...
+ functions: required API eventarc.googleapis.com is enabled
+ functions: required API pubsub.googleapis.com is enabled
+ functions: required API run.googleapis.com is enabled
+ functions: required API storage.googleapis.com is enabled
i functions: generating the service identity for pubsub.googleapis.com...
i functions: generating the service identity for eventarc.googleapis.com...
24c.zip?GoogleAccessId=service-372042583890%40gcf-admin-robot.iam.gserviceaccount.com&Expires=1709026786&Signature=JfBwxH%2BIfbth7FfVGpUUKLC%2FXgoOscYD153RtpZ
V2zLLpq1lH4%2FZEsD7hJn7s3SI0YxHN41NAWdZ0O6tzpEKBMse%2B7s%2FFkLxhlKIP4YJL9%2F6BAEzKYabew5IXL%2FzrQhALT%2B%2FxuahbJrKlB%2FJwRioaOoMIy8ay6r2DU1gEzY%2BwoCh9snoa%2
Error: Failed to make request to https://storage.googleapis.com/gcf-v2-uploads-372042583890-us-central1/3a8f57d9-815f-4959-94a4-b856fe06524c.zip?GoogleAccessI
d=service-372042583890%40gcf-admin-robot.iam.gserviceaccount.com&Expires=1709026786&Signature=JfBwxH%2BIfbth7FfVGpUUKLC%2FXgoOscYD153RtpZCNiwpaZQJ838LMXFagkLf
7crUQ0KsBKOp315T8OkMobIkFS6WsqgeXk3CqflqH1%2BNoktwhNOg097gQxVJbTPJiDESMuZI6iu3r90xWLvozblce6N5OkHnUbzbYCCo3x0NeuaCpYGO%2F3tUiLp%2FjgwMxKbV2zLLpq1lH4%2FZEsD7hJ
n7s3SI0YxHN41NAWdZ0O6tzpEKBMse%2B7s%2FFkLxhlKIP4YJL9%2F6BAEzKYabew5IXL%2FzrQhALT%2B%2FxuahbJrKlB%2FJwRioaOoMIy8ay6r2DU1gEzY%2BwoCh9snoa%2B0Dw2Q8oihoAQ%3D%3D
当我运行 firebase 函数:日志时,这就是我得到的
2024-02-26T09:09:39.997131Z I undefined: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"mygmailaccount@
gmail.com","principalSubject":"user:[email protected]"},"requestMetadata":{"callerIp":"41.116.70.216","callerSuppliedUserAgent":"FirebaseCLI/13.3.1,
gzip(gfe),gzip(gfe)","requestAttributes":{"time":"2024-02-26T09:09:50.029165Z","auth":{}},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis
.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.GenerateUploadUrl","authorizationInfo":[{"resource":"projects/revival-academy/locations/us
-central1","permission":"cloudfunctions.functions.sourceCodeSet","granted":true,"resourceAttributes":{},"permissionType":"ADMIN_WRITE"}],"resourceName":"proje
cts/revival-academy/locations/us-central1","request":{"@type":"type.googleapis.com/google.cloud.functions.v1.GenerateUploadUrlRequest","parent":"projects/revi
val-academy/locations/us-central1"},"response":{"@type":"type.googleapis.com/google.cloud.functions.v1.GenerateUploadUrlResponse","uploadUrl":"https://storage
.googleapis.com/uploads-912355258456.us-central1.cloudfunctions.appspot.com/c3b23a83-e243-4a26-a87b-7842da5131ee.zip?GoogleAccessId=service-372042583890@gcf-a
dmin-robot.iam.gserviceaccount.com&Expires=1708940389&Signature=WwYbBXHMpzn%2B5alLVKmmJ8MeoiQgSUJIZWHWvWE2ZLuUHaVDgHlm7vtb7sT9pZ2%2BKL72Ukyp11to5dKkWBLDdPqTdk
Lifw0f0u9qBqaoXvmUTdLMTwqG4HafE70rKMvoEmhuaXeOVicVwFg7CZ%2F28XpEfEi4cW5tod4UxjAUoDqUWQ6l%2FoR9Y1Ax0LErWZKoIPMDGtxfDcTeOnQJG5gFnSowkuqXzeAfosuOdWe8AySUf%2Fli%2
F0Zs0EDZV3lAjxQUxhbjpiGOaxjx3ub0kNRNhKkdqUMTZWxFFPFHcCsg2%2B7ABom9%2BEn7Z4jazitDehhLlMS0F5SLtBYqG%2BGbywYRjQ%3D%3D"},"resourceLocation":{"currentLocations":["
us-central1"]}}
2024-02-26T09:09:49.969070Z I undefined: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{},"authenticationInfo":{},"serviceName":"cloudfu
nctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.GenerateUploadUrl","resourceName":"projects/revival-academy/locations/us
-central1"}
2024-02-26T10:24:16.848004Z I undefined: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"mygmailaccount@
gmail.com","principalSubject":"user:[email protected]"},"requestMetadata":{"callerIp":"41.116.70.216","callerSuppliedUserAgent":"FirebaseCLI/13.3.1,
gzip(gfe),gzip(gfe)","requestAttributes":{"time":"2024-02-26T10:24:17.401683Z","auth":{}},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis
.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.GenerateUploadUrl","authorizationInfo":[{"resource":"projects/revival-academy/locations/us
-central1","permission":"cloudfunctions.functions.sourceCodeSet","granted":true,"resourceAttributes":{},"permissionType":"ADMIN_WRITE"}],"resourceName":"proje
cts/revival-academy/locations/us-central1","request":{"parent":"projects/revival-academy/locations/us-central1","@type":"type.googleapis.com/google.cloud.func
tions.v1.GenerateUploadUrlRequest"},"response":{"@type":"type.googleapis.com/google.cloud.functions.v1.GenerateUploadUrlResponse","uploadUrl":"https://storage
.googleapis.com/uploads-912355258456.us-central1.cloudfunctions.appspot.com/ef7bec94-6892-45e1-9eec-94117d87c6d5.zip?GoogleAccessId=service-372042583890@gcf-a
dmin-robot.iam.gserviceaccount.com&Expires=1708944857&Signature=EVnYh7DbBzLp4lVFp%2BDMFeTT7LZhpEPyrWRxIjAfWNmlpCD4yuF9rDvqbVnMHcu0PRAlYi0Vq2UDKA%2F6IAOQpOXKxS
hCP3EN53v6fbgUK9WpsBqW1h8L12wGHmYltubugp5p5xogpj4FzF3F254UsocwyirqhkJekgauD27aqNd5k5dIUsfVEf3K080la1IbfPGdaVg2KIskmDl%2FcixKJ7ejZJOWjbOpQ5KmX%2FDcYdJLAXCrwTdZ
CorjCe%2FIS%2FPwXPomvogWX83JeQXSqgcX1MYxtwmZB7MPoiWvAfg2P6xPmVqSsqF7%2BYbmVjs3vmsSYoY00tfoS5Mawl3EBJJSFg%3D%3D"},"resourceLocation":{"currentLocations":["us-c
entral1"]}}
2024-02-26T10:24:17.339854Z I undefined: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{},"authenticationInfo":{},"serviceName":"cloudfu
nctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.GenerateUploadUrl","resourceName":"projects/revival-academy/locations/us
-central1"}
2024-02-26T10:49:45.922920Z I undefined: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","authenticationInfo":{"principalEmail":"mygmailaccount@
gmail.com","principalSubject":"user:[email protected]"},"requestMetadata":{"callerIp":"41.116.70.216","callerSuppliedUserAgent":"FirebaseCLI/13.3.1,
gzip(gfe),gzip(gfe)","requestAttributes":{"time":"2024-02-26T10:49:46.453098Z","auth":{}},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis
.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.GenerateUploadUrl","authorizationInfo":[{"resource":"projects/revival-academy/locations/us
-central1","permission":"cloudfunctions.functions.sourceCodeSet","granted":true,"resourceAttributes":{},"permissionType":"ADMIN_WRITE"}],"resourceName":"proje
cts/revival-academy/locations/us-central1","request":{"parent":"projects/revival-academy/locations/us-central1","@type":"type.googleapis.com/google.cloud.func
tions.v1.GenerateUploadUrlRequest"},"response":{"@type":"type.googleapis.com/google.cloud.functions.v1.GenerateUploadUrlResponse","uploadUrl":"https://storage
.googleapis.com/uploads-912355258456.us-central1.cloudfunctions.appspot.com/34727eaa-ef53-47e6-874b-43d816936e61.zip?GoogleAccessId=service-372042583890@gcf-a
dmin-robot.iam.gserviceaccount.com&Expires=1708946386&Signature=rQvCv9G58vFhTe86pRX%2B0kMS9RlzyuZtkBmPYcFwxIiNfndaLvaI7WknqKHYJ57oqHop%2BOxE%2Fs1OmYdK8PrReJIz
YMG7jXtbrvSFZvPAu8ctMP7ekH8o1nrC5eLknnx8hLVEFZfbAOuoLH0%2FJgleqgMymTkRpa%2BXuzARqzns%2BZvEXHdMiurhxKoBZ7XnGA2hJx%2BNRfYgxBElVH7xiBE0T2%2Fp5VFdsJmnNgugo%2BkHn0
nJ%2FZUpWUuTHePoF3UNQc6pT01caA1MT3n189%2FybDkXU8IydrDTM0oZIquckcJkvi5bRI7iwieK2MM4L5YxBBNH8j%2FZznZl3vd715pCdjmVJg%3D%3D"},"resourceLocation":{"currentLocatio
ns":["us-central1"]}}
2024-02-26T10:49:46.393437Z I undefined: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{},"authenticationInfo":{},"serviceName":"cloudfu
nctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.GenerateUploadUrl","resourceName":"projects/revival-academy/locations/us
-central1"}
我尝试重新安装 firebase 工具、节点,并重新验证我的帐户,我还运行 npm run lint 并在重新创建函数文件夹后尝试部署不同的函数。
更改我用来访问互联网连接的设备就可以了。