Table of Contents
Firebase Functionを使ってみようと、プロジェクトを作って、初回のデプロイをしよう思ったら、いきなりつまづいた。
環境
- macOS Mojave:10.14.5
- node:v12.4.0
- npm:6.10.0
- firebase-tools:7.0.2
関数をデプロイする手順
# Firebase ツールをインストール
$ npm install -g firebase-tools
# プロジェクトのディレクトリを作成
$ mkdir hoge
# プロジェクトのディレクトリへ移動
$ cd hoge
# プロジェクトの初期化
$ firebase init
# サービス、プロジェクト、設定ファイルなどを方向キーとスペースで選択し、Enterを押す
# ○Functions: Configure and deploy Cloud Functions
# スペースで選択してEnter
#
# プロジェクトをスペースで選択
#
# TypeScriptを選択
# ? What language would you like to use to write Cloud Functions? (Use arrow keys)
# JavaScript
# ❯ TypeScript
#
# あとだいたい「Y」で!!
# functionsへ移動
$ cd functions
# 最初の関数をデプロイする
$ firebase deploy
チュートリアルなのにエラーってどういうこと
firebase deploy
Error: An unexpected error has occurred.
package.jsonのscriptにかいてるあるdeployを試してみる
# function指定でデプロイ
$ npm run deploy
エラー
> functions@ deploy /Users/hoge-user/workspace/hoge/functions
> firebase deploy --only functions
Error: An unexpected error has occurred.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ deploy: `firebase deploy --only functions`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hoge-user/.npm/_logs/2019-07-07T09_40_15_556Z-debug.log
ログを確認
/Users/hoge-user/workspace/hoge/firebase-debug.log
・
・
・
[debug] [2019-07-07T09:40:14.286Z] <<< HTTP RESPONSE 200
[debug] [2019-07-07T09:40:15.281Z] TypeError: Cannot read property 'wanted' of undefined
at /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
at processTicksAndRejections (internal/process/task_queues.js:89:5)
[error]
[error] Error: An unexpected error has occurred.
解決したStack Overflow
TypeError: Cannot read property 'wanted' of undefined:
I have been deploying functions with firebase successfully all day learning how to use it. I was trying to see what happ...
checkFirebaseSDKVersion.jsの34行目を修正
/usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js
- if (!output) {
+ if (!output || !output["firebase-functions"]) {