
Firebase | Google | w3HexSchool
Firebase-tools 工具初始化專案
建立 Firebase 專案
首先先到 Firebase Console 建立一個新的專案

Firebase-tools 工具安裝
Filebase Cli 工具我們去 npm 安裝 – Filebase-tools npm
# Mac 用戶可能需要加個 sudo !!! $ npm install -g firebase-tools
firebase-tools 使用
使用之前要先 login
$ firebase login # 稍微介紹一下CLI工具 i Firebase optionally collects CLI usage and error reporting information to help improve our products. ... ## (詢問是否同意隱私政策 當然同意就好) ? Allow Firebase to collect CLI usage and error reporting information? (Y/n) y ## 同意之後他會跳出一場串網址請你按進去(按不進去複製起來丟到瀏覽器就可以了) i To change your data collection preference at any time, run `firebase logout` and log in again. Visit this URL on any device to log in: https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=796048600&redirect_uri=http%3A%2F%2Flocalhost%3A9005 ## 等待登入授權 Waiting for authentication... ## 登入授權後的成功訊息 ✔ Success! Logged in as judysocute@gmail.com
授權成功後就可以開始使用我們的 firebase-tools 開啟我們的 Firebase project 了
開啟專案
# 首先 建立工作目錄,再進去工作目錄 $ mkdir firebase-cloud-functions $ cd firebase-cloud-functions # 初始化專案 $ firebase init ######## #### ######## ######## ######## ### ###### ######## ## ## ## ## ## ## ## ## ## ## ## ###### ## ######## ###### ######## ######### ###### ###### ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ######## ######## ## ## ###### ######## You are about to initialize a Firebase project in this directory: # 提醒你即將在這個目錄初始化 Firebase 專案 /your/path/firebase-cloud-functions # 選擇這次要用到的 CLI 工具 Which Firebase CLI features do you want to set up for this folder? Press Space to select feat ures, then Enter to confirm your choices. (Press <space> to select, <a> to toggle all, <i> to invert selection) ◯ "Database: Deploy Firebase Realtime Database Rules" ◯ "Firestore: Deploy rules and create indexes for Firestore" # 這次專案只要用到這個就好了 ❯◉ "Functions: Configure and deploy Cloud Functions" ◯ "Hosting: Configure and deploy Firebase Hosting sites" ◯ "Storage: Deploy Cloud Storage security rules" # 專案設定 === Project Setup first ... # 以下省略 # 綁定一個之後要部署上去的 Project # 其實之後也可以用 --add 指令加上去(不過我也沒用過) ? Please select an option: (Use arrow keys) # 使用現有的專案(這次選這個就好 選取後再選擇當初第一步建立的專案) ❯ "Use an existing project " # 建立新專案 "Create a new project " # 把 Firebase 加到一個現有的 Google 服務專案中(看不懂XDD) "Add Firebase to an existing Google Cloud Platform project " # 不要設定 "Don't set up a default project " ... ... # 接下來選擇撰寫語言、Lint 可以選 JavaScript 或 TypeScript 就自己選一選吧~~ # 最後是問你說 要不要直接幫你跑一次 npm install 就一路 "Y" 下去吧 ? Do you want to install dependencies with npm now? (Y/n)
初始專案一覽

初始專案就到這邊吧!下次再開始正式使用 🙂
No Comment