firebase - firestore 在云功能教程中的模拟器中不起作用
问题描述
我按照教程https://firebase.google.com/docs/functions/get-started(从头开始两次),firestore 是空白的。
请注意,在我需要初始化 Firestore 的步骤 3.3 中,我按照控制台中的步骤操作并在 Web 上对其进行了初始化
firebase 模拟器套件的日志http://localhost:4000/logs
12:19:34 I ui Emulator UI logging to ui-debug.log 12:19:35 I functions Watching "/home/kirill/try-function-d8787/functions" for Cloud Functions...
12:19:36 I functions http function initialized (http://localhost:5001/try-function-d8787/us-central1/addMessage).
12:19:36 I functions firestore function initialized. 12:19:36 I
┌───────────────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! View status and logs at http://localhost:4000 │
└───────────────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ localhost:5001 │ http://localhost:4000/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ localhost:8080 │ http://localhost:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
Other reserved ports: 4400, 4500
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the*-debug.log files.
12:22:34 I function[addMessage] Beginning execution of "addMessage"
12:22:35 I function[addMessage] Finished "addMessage" in ~1s
12:22:35 I function[makeUppercase] Beginning execution of "makeUppercase"
12:22:36 I function[makeUppercase] { "severity": "INFO", "message": "Uppercasing Md0HKOGNHNVo7pk9hhbq uppercaseme" }
12:22:36 I function[makeUppercase] Finished "makeUppercase" in ~1s
火库选项卡:
终端日志(不知道如何正确发布):
~ ❯❯❯ cd try-function-d8787 ~/try-function-d8787 ❯❯❯ firebase login Already logged in as kirill.igum@gmail.com ~/try-function-d8787 ❯❯❯ firebase init firestore
✘ 1 ######## #### ######## ######## ######## ### ###### ######## ## ## ## ## ## ## ## ## ## ## ## ###### ## ######## ###### ######## ######### ###### ###### ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/home/kirill/try-function-d8787
=== Project Setup
First, let's associate this project directory with a Firebase project. You can create multiple project aliases by running firebase use --add, but for now we'll just set up a default project.
? Please select an option: Use an existing project ? Select a default Firebase project for this directory: try-function-d8787 (try-function) i Using project try-function-d8787 (try-function)
=== Firestore Setup
Firestore Security Rules allow you to define how and when to allow requests. You can keep these rules in your project directory and publish them with firebase deploy.
? What file should be used for Firestore Rules? firestore.rules Firestore indexes allow you to perform complex queries while maintaining performance that scales with the size of the result set. You can keep index definitions in your project directory and publish them with firebase deploy. ? What file should be used for Firestore indexes? firestore.indexes.json i Writing configuration info to firebase.json... i Writing project information to .firebaserc... i Writing gitignore file to .gitignore...
✔ Firebase initialization complete! ~/try-function-d8787 ❯❯❯ firebase init functions
[3/87] ######## #### ######## ######## ######## ###
###### ######## ## ## ## ## ## ## ## ## ## ## ## ###### ## ######## ###### ######## ######### ###### ###### ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/home/kirill/try-function-d8787
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
=== Project Setup
First, let's associate this project directory with a Firebase project. You can create multiple project aliases by running firebase use --add, but for now we'll just set up a default project.
i .firebaserc already has a default project, using try-function-d8787.
=== Functions Setup
A functions directory will be created in your project with a Node.js package pre-configured. Functions can be deployed with firebase deploy.
? What language would you like to use to write Cloud Functions? JavaScript ? Do you want to use ESLint to catch probable bugs and enforce style? Yes ✔ Wrote functions/package.json ✔ Wrote functions/.eslintrc.json ✔ Wrote functions/index.js ✔ Wrote functions/.gitignore ? Do you want to install dependencies with npm now? Yes
> protobufjs@6.10.1 postinstall /home/kirill/try-function-d8787/functions/node_modules/protobufjs
> node scripts/postinstall
npm notice created a lockfile as package-lock.json. You should commit this file. added 360 packages from 263 contributors and audited 360 packages in
11.852s
34 packages are looking for funding run `npm fund` for details
found 0 vulnerabilities
i Writing configuration info to firebase.json... i Writing project information to .firebaserc...
✔ Firebase initialization complete! ~/try-function-d8787 ❯❯❯ ls functions firebase.json firestore.indexes.json firestore.rules ~/try-function-d8787 ❯❯❯ cd functions ~/t/functions ❯❯❯ vim index.js ~/t/functions ❯❯❯ cd .. ~/try-function-d8787 ❯❯❯ firebase emulators:start i emulators: Starting emulators: functions, firestore ⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, hosting, pubsub ✔ functions: Using node@10 from host. i firestore: Firestore Emulator logging to firestore-debug.log i ui: Emulator UI logging to ui-debug.log i functions: Watching "/home/kirill/try-function-d8787/functions" for Cloud Functions... ✔ functions[addMessage]: http function initialized (http://localhost:5001/try-function-d8787/us-central1/addMessage). ✔ functions[makeUppercase]: firestore function initialized.
┌───────────────────────────────────────────────────────────────────────┐ │ ✔ All emulators ready! View status and logs at http://localhost:4000 │ └───────────────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐ │ Emulator │ Host:Port │ View in Emulator UI │ ├───────────┼────────────────┼─────────────────────────────────┤ │ Functions │ localhost:5001 │ http://localhost:4000/functions │ ├───────────┼────────────────┼─────────────────────────────────┤ │ Firestore │ localhost:8080 │ http://localhost:4000/firestore │ └───────────┴────────────────┴─────────────────────────────────┘ Other reserved ports: 4400, 4500
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the
*-debug.log files.
i functions: Beginning execution of "addMessage" i functions: Finished "addMessage" in ~1s i functions: Beginning execution of "makeUppercase"
> {"severity":"INFO","message":"Uppercasing Md0HKOGNHNVo7pk9hhbq uppercaseme"} i functions: Finished "makeUppercase" in ~1s
解决方案
Firebase 模拟器现在不能在 WSL2 上运行。我通过使用带有 nodejs/npm 的 Windows 安装的 git-bash 控制台解决了这个问题
推荐阅读
- python - 如何打印数字列表但在 IDLE 中像金字塔方式一样计数
- c - C中输入和输出的缓冲区是否不同?
- python - 将一行的值与 Pandas 中的多个值进行比较?
- python - 我怎样才能在我的输出中包含小数?
- javascript - jQuery复选框功能根据最大数据获取ID
- algorithm - 如何简化将数据地址粘贴到机器代码中的立即字段的算法?
- android - 由于 META-INF,使用 Detox 和 JSI 进行测试失败
- pyspark - 过滤 RDD 文件
- haskell - 在 IO (Haskell) 中使用 mapM 函数打印键值元组列表的内容
- python - 如何使用pytest测试处理请求的Flask(非路由)函数?