我是Firebase的新手。试图弄清楚它是如何工作的。我已经成功创建并部署了Firebase函数。当我尝试在本地运行它时,出现错误。
因此,当我开始研究如何在本地运行firebase函数时。我发现了这两种方法。
1)firebase serve
命令
2)使用Firebase模拟器https://firebase.google.com/docs/functions/local-emulator
当我尝试使用第二种方法运行时,它可以很好地工作,我可以在本地调用函数,也可以将数据添加到firestore中。
但是当我尝试使用firebase serve
在本地运行函数时,这就是我得到的错误。
=== Serving from '/Users/shashank/Desktop/Learning Projects/socialApp'...
⚠ Your requested "node" version "8" doesn't match your global version "12"
✔ functions: Emulator started at http://localhost:5000
i functions: Watching "/Users/shashank/Desktop/Learning Projects/socialApp/functions" for Cloud Functions...
✔ functions[helloWorld]: http function initialized (http://localhost:5000/socialapp-8f2db/us-central1/helloWorld).
✔ functions[getScreams]: http function initialized (http://localhost:5000/socialapp-8f2db/us-central1/getScreams).
✔ functions[createStreams]: http function initialized (http://localhost:5000/socialapp-8f2db/us-central1/createStreams).
i functions: Beginning execution of "createStreams"
> Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
> at GoogleAuth.getApplicationDefaultAsync (/Users/shashank/Desktop/Learning Projects/socialApp/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:161:19)
> at processTicksAndRejections (internal/process/task_queues.js:93:5)
> at async GoogleAuth.getClient (/Users/shashank/Desktop/Learning Projects/socialApp/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:503:17)
> at async GrpcClient._getCredentials (/Users/shashank/Desktop/Learning Projects/socialApp/functions/node_modules/google-gax/build/src/grpc.js:108:24)
> at async GrpcClient.createStub (/Users/shashank/Desktop/Learning Projects/socialApp/functions/node_modules/google-gax/build/src/grpc.js:229:23)
我想了解这种方法出了什么问题。任何帮助表示赞赏。预先感谢。