2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Firebase init でいつもつまづくのでメモっとく

Last updated at Posted at 2020-10-25

Actions On Googleを久しぶりに作ろうとしてググっていたところ、Actions on googleの場合のwebhooksというかAPIの定番はFirebaseホスティングだと聞いたので、苦手なFirebase CLIをまた叩いてみました。

仕事でもApp EngineへのデプロイなどでFirebase CLIを使っているので、環境が混ざらないようにするTipsが必要だったため、忘れないようにメモっておきます。

ActionOnGoogle用のFirebaseプロジェクトは、こちらの手順通りに進めて、Firebaseのコンソールでプロジェクトを作ってある状態からスタートです。

firebase cliはすでにインストールしてある状態です。

Macローカルに作業用ディレクトリを作成します。

cd ~/workspace
mkdir googleAssistant
cd googleAssistant

仕事でも若干Webサイトのデプロイなどで使うのでfirebase cliを使っているので、まずアカウントを変更するためにログオフします。 プロジェクトのエイリアスを止める方法は、こちらを参照させていただきました。

firebase logout
firebase use --clear
firebase use --unalias default
firebase login

ブラウザが開くので、個人の方のアカウントでログイン。

firebase projects:list
 →Firebaseのコンソールで作ったプロジェクトが、この一覧に出てくる事を確認。

firebase use --add プロジェクトID

ではいよいよ、雛形を作成します。

firebase init

You're about to initialize a Firebase project in this directory:
  /Users/sitopp

あれ???
ナンデ?

このまま作ると /Users/sitopp 以下に firebase.jsonなどを生成してしまうため、現在地=作業用のディレクトリを向いていなければならないのに。。

いろいろ調べていて、PATHが通ってないのかなと思い、こちらの記事を参考に、パスを追加しました。ありがとうございます。
https://qiita.com/ebichan_88/items/e3e30461ad4ddd9368f5

調査方法:

npm bin -g

→結果が
/Users/sitopp/.nodebrew/node/v10.16.3/bin
(not in PATH env variable)
とのように2行目のメッセージが出てしまってたので、パスが通っていない事がわかりました。

export PATH=$PATH:`npm bin -g`

と実行してから、

npm bin -g

→結果は
/Users/sitopp/.nodebrew/node/v10.16.3/bin
となります。今度は(not in PATH env variable)は出てこなかったので良いはず。

再度、初期化を実行

firebase init

You're about to initialize a Firebase project in this directory:
/Users/sitopp/workspace/googleAssistant
と出たので、今度は良さそう。
続けて、必要な回答を打ち込んでいきます。

=== Project Setup


? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices.
 上下移動してスペースキーで Functions, Hosting にチェックを入れ、エンター。

? Please select an option: Use an existing project
? Select a default Firebase project for this directory: プロジェクトID (プロジェクト名ではなくID)
? 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? No
? Do you want to install dependencies with npm now? Yes


=== Hosting Setup

? What do you want to use as your public directory? public
? Configure as a single-page app (rewrite all urls to /index.html)? No
? Set up automatic builds and deploys with GitHub? Yes

? For which GitHub repository would you like to set up a GitHub workflow? sitopp/リポジトリ名


? Set up the workflow to run a build script before every deploy? No
? GitHub workflow file for PR previews exists. Overwrite? firebase-hosting-pull-request.yml Yes

? Set up automatic deployment to your site's live channel when a PR is merged? Yes
? What is the name of the GitHub branch associated with your site's live channel? main
? The GitHub workflow file for deploying to the live channel already exists. Overwrite? firebase-hosting-merge.yml Yes

✔  Firebase initialization complete!

できました。あーよかった。

途中、ディスクが100%になっててFirebase toolのインストールができなかったので不要ファイルも整理しました。とことん相性悪いなぁ。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?