【发布时间】:2021-01-03 18:26:57
【问题描述】:
我按照教程https://firebase.google.com/docs/functions/get-started(从头开始两次),firestore 是空白的。
注意,在步骤 3.3 中我需要初始化 firestore,我按照控制台中的步骤并在网络上对其进行了初始化
来自 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
firestore 标签:
终端日志(不知道如何正确发布):
~ ❯❯❯ 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
【问题讨论】:
-
我已经完成了本教程,一切正常。您遇到的是什么浏览器和操作系统?
-
@vitooh Google Chrome 版本 85.0.4183.102(官方版本)(64 位)。 wsl 2 上的 Ubuntu 20.04
-
不幸的是,我没有任何 Windows 机器可以尝试这个。但是,如果我理解正确,您在 WSL 中启动了模拟器,并且您正试图从 Windows 访问它...?
-
模拟器总是从空的开始,除非你明确地加载数据。你写过代码来添加数据吗?
-
我仍然无法运行 WSL,但是您可能会发现在云 shell 中运行模拟器并在云 shell 预览中打开 GUI 的行为相同。我建议将此案例提交给 Firebase 支持:firebase.google.com/support/troubleshooter/report/bugs
标签: firebase google-cloud-firestore google-cloud-functions firebase-cli wsl-2