当尝试使用云功能仿真器时,我收到一条消息,指出:
function ignored because the firestore emulator does not exist or is not running
我尝试在这里提到(Firestore/Firebase Emulator Not Running)。
我的functions / package.json看起来像这样:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.1.6"
},
"private": true
}
我用来启动模拟器的命令:
firebase emulators:start --only functions
这是我得到的输出:
i Starting emulators: ["functions"]
! Your requested "node" version "8" doesn't match your global version "10"
+ functions: Emulator started at http://localhost:5001
i functions: Watching "C:\Users\MyName\Documents\MyProject\functions" for Cloud Functions...
i functions[updateFunction]: function ignored because the firestore emulator does not exist or is not running.
+ All emulators started, it is now safe to connect.
我在功能中正在执行console.log,但是在端口(5001)上看不到它。
任何帮助将不胜感激。
答案 0 :(得分:1)
如果要触发Firestore功能,则需要在本地Firestore模拟器中进行更改。本地模拟的功能不响应实际的云托管数据库。所有产品上的仿真必须是本地的。
答案 1 :(得分:0)
虽然模拟器是测试应用程序的绝佳选择,但无服务器端到端测试又如何呢?例如,您可以将Endly自动化运行程序与专用的GCP测试项目一起使用。
Here,您可以找到更多有关如何在专用GCP项目上测试无服务器应用程序的信息。
答案 2 :(得分:0)
functions[updateFunction]: function ignored because the firestore emulator does not exist or is not running.
也许'updateFunction'是用于监视Firestore文档更改的处理函数,不是吗?
因此,您可能需要同时使用功能启动firestore。
使用firebase.json配置仅在不使用--only选项的情况下执行
{
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
},
"functions": {
"source": "functions"
},
"emulators": {
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"hosting": {
"port": 5000
},
"ui": {
"enabled": true,
"host": "localhost",
"port": 4000
}
}
}
如果要将服务器端功能与IDE连接进行调试,则需要使用“ --inspect-functions”选项,或者只需要在仿真器日志页面“ http:// localhost:中检查日志”即可。 4000 / logs“
firebase emulators:start --inspect-functions