Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 云Firestore模拟器未运行,因此对Firestore的调用将影响生产_Node.js_Reactjs_Firebase_Google Cloud Firestore_Firebase Tools - Fatal编程技术网

Node.js 云Firestore模拟器未运行,因此对Firestore的调用将影响生产

Node.js 云Firestore模拟器未运行,因此对Firestore的调用将影响生产,node.js,reactjs,firebase,google-cloud-firestore,firebase-tools,Node.js,Reactjs,Firebase,Google Cloud Firestore,Firebase Tools,我正在学习firebase与我的react web应用程序集成。我试图为GET和POST请求编写函数,并使用在vscode中的终端中获得的端点在postman上运行它们。 现在,我的代码与firebase deploy完美配合,但在尝试使用firebase Service时出现错误。此外,我不能简单地使用这些命令,我必须使用sudo运行它们,然后输入密码,然后才能运行它们。 下面是错误列表 云Firestore模拟器未运行,因此对Firestore的调用将影响生产 ⚠ 请求外部网络资源! -网

我正在学习firebase与我的react web应用程序集成。我试图为GET和POST请求编写函数,并使用在vscode中的终端中获得的端点在postman上运行它们。 现在,我的代码与firebase deploy完美配合,但在尝试使用firebase Service时出现错误。此外,我不能简单地使用这些命令,我必须使用sudo运行它们,然后输入密码,然后才能运行它们。 下面是错误列表

云Firestore模拟器未运行,因此对Firestore的调用将影响生产

⚠ 请求外部网络资源! -网址:“ -小心,这可能是生产服务

⚠ 请求外部网络资源! -网址:“ -小心,这可能是生产服务

错误:无法加载默认凭据。浏览以了解更多信息

 at GoogleAuth.getApplicationDefaultAsync (/home/nikunj/socialape-functions/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:160:19)

 at processTicksAndRejections (internal/process/task_queues.js:97:5)

 at async GoogleAuth.getClient (/home/nikunj/socialape-functions/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:502:17)

 at async GrpcClient._getCredentials (/home/nikunj/socialape-functions/functions/node_modules/google-gax/build/src/grpc.js:92:24)

 at async GrpcClient.createStub (/home/nikunj/socialape-functions/functions/node_modules/google-gax/build/src/grpc.js:213:23)
原因:错误

 at WriteBatch.commit (/home/nikunj/socialape-functions/functions/node_modules/@google-cloud/firestore/build/src/write-batch.js:415:23)

 at DocumentReference.create (/home/nikunj/socialape-functions/functions/node_modules/@google-cloud/firestore/build/src/reference.js:283:14)
 at CollectionReference.add (/home/nikunj/socialape-functions/functions/node_modules/@google-cloud/firestore/build/src/reference.js:2011:28)
 at /home/nikunj/socialape-functions/functions/index.js:32:10
 at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:559:20
 at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:534:19
 at Generator.next (<anonymous>)
 at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:8:71
 at new Promise (<anonymous>)
 at __awaiter (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:4:12)
在WriteBatch.commit(/home/nikunj/socialape functions/functions/node_modules/@google cloud/firestore/build/src/write batch.js:415:23)
在DocumentReference.create(/home/nikunj/socialape functions/functions/node_modules/@google cloud/firestore/build/src/reference.js:283:14)
在CollectionReference.add(/home/nikunj/socialape functions/functions/node_modules/@google cloud/firestore/build/src/reference.js:2011:28)
at/home/nikunj/socialape functions/functions/index.js:32:10
at/usr/local/lib/node_modules/firebase tools/lib/emulator/functionsemulatoruntime.js:559:20
at/usr/local/lib/node_modules/firebase tools/lib/emulator/functionsemulatoruntime.js:534:19
在Generator.next()处
at/usr/local/lib/node_modules/firebase tools/lib/emulator/functionsemulatoruntime.js:8:71
在新的承诺()
在等待者处(/usr/local/lib/node\u modules/firebase tools/lib/emulator/functionsEmulatorRuntime.js:4:12)
i功能:在~1s内完成“CreateShray”


实际上,我通过在firebase项目设置中使用服务帐户提供凭据来解决这个问题。我将我的初始化应用程序更改为

    var serviceAccount = require("path/to/serviceAccountKey.json");

    admin.initializeApp({
     credential: admin.credential.cert(serviceAccount),
     databaseURL: "https://socialape-6925b.firebaseio.com"
     });```

对我来说,缺少的一步是我没有使用初始化firestore仿真器

firebase init emulators

是的,我也有同样的错误,但我解决了这个问题

首先,确保项目文件夹中有.firebaserc文件 然后使用以下命令初始化管理员:-

admin.initializeApp();

我仍然不明白这些东西是如何工作的,我所做的只是在线检查解决方案,并尝试了解哪些更改可以帮助我:)