---
# System prepended metadata

title: Firebase Hosting に Node.js Webアプリをデプロイする　2021-05-12
tags: [Firebase Hosting, Node.js, Firebase Functions]

---

---
lang: ja-jp
breaks: true
---
# Firebase Hosting に Node.js Webアプリをデプロイする　2021-05-12

> Firebase を JavaScript プロジェクトに追加する
> https://firebase.google.com/docs/web/setup?hl=ja

> Node.js によるアプリを Firebase で Hosting する最短の道
> https://qiita.com/Satachito/items/c175645644af759cc71c

## プロジェクトを作成
```shell=
$ firebase init hosting
$ firebase init functions
```

```shell=
$ du -a | grep -v 'node_modules' | grep -v '.git'
4       ./firebase.json
8       ./public/index.html
12      ./public
4       ./functions/index.js
72      ./functions/package-lock.json
4       ./functions/package.json
64208   ./functions
4       ./.firebaserc
64424   .
```

## 静的コンテンツを確認

```shell=
$ firebase serve
```

## 動的コンテンツを確認

```shell=
$ firebase serve --only functions
```

## デプロイ
```shell=
$ firebase deploy 
```

:::warning
:warning: Blaze (pay-as-you-go) プランに変更しないと使えないとのこと。
```shell=
$ firebase deploy 

=== Deploying to 'xxxx-19a62'...

i  deploying functions, hosting
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
⚠  functions: missing required API cloudbuild.googleapis.com. Enabling now...

Error: Your project xxxx-19a62 must be on the Blaze (pay-as-you-go) plan to complete this command. Required API cloudbuild.googleapis.com can't be enabled until the upgrade is complete. To upgrade, visit the following URL:

https://console.firebase.google.com/project/xxxx-19a62/usage/details
```
:::

###### tags: `Firebase Hosting` `Node.js` `Firebase Functions`
