firebase Firebase Functionsメモ

本稿について

本稿はサイト運営者が学んだことなどを記したメモの内容です。
全てが正確な情報とは限りません。ご注意ください。また修正するべき点は適時修正していきます
事前にnpmなどの環境は用意しておく

2020年10月現在、firebase functionsは以下のnodeバージョンで動くらしい
node8 , node10, node12(ベータ)

現時点では 以下のversionを利用する
v10.22.1

$ firebase init
=== 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: xxxx (xxxxx)
i  Using project xxxxxxxx (xxxxxxx)


=== 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? No
✔  Wrote functions/package.json
✔  Wrote functions/index.js
✔  Wrote functions/.gitignore
? Do you want to install dependencies with npm now? Yes


> protobu[email protected] postinstall xxxxxxx/functions/node_modules/protobufjs
> node scripts/postinstall


npm notice created a lockfile as package-lock.json. You should commit this file.
added 256 packages from 203 contributors and audited 256 packages in 8.658s


32 packages are looking for funding
  run `npm fund` for details


found 4 high severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details


i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...


✔  Firebase initialization complete!

※ もしくは “firebase init functions” でも大丈夫
※ もし事前に “package.json”を作成してしまっている場合には
以下を追記しておく
"engines": {"node": "10"}

[参考]

使うプロジェクトを選択する
$ firebase use xxxx




以下のエラーが表示された
Server Error. connect ETIMEDOUT 104.197.85.31:443

しばらくしたらエラーが治った。 google のfirebaseのサーバーが落ちたのだろうか?



localでエミュレートする
$ firebase emulators:start



テスト



[参考]

関連ページ

■ firebase

#firebase
Back