Firebaseへのdeploy時のエラー対応

FirebaseへWebアプリをデプロイしようとした時にTypeError: Cannot read property 'wanted' of undefinedというエラーが出た。その対処の備忘録。

エラー内容

既に別のアプリケーションをデプロイしたことのあるFirebaseプロジェクトへ追加で別のWebアプリをデプロイしようとした。(管理画面的なやつ)

firebase deploy したところ、以下のようなログが出ていた

[debug] [2019-12-25T07:48:11.929Z] ----------------------------------------------------------------------
[debug] [2019-12-25T07:48:11.932Z] Command:       /Users/{user-name}/.nodebrew/node/v11.10.0/bin/node /Users/{user-name}/.nodebrew/current/bin/firebase deploy
[debug] [2019-12-25T07:48:11.932Z] CLI Version:   7.0.2
[debug] [2019-12-25T07:48:11.932Z] Platform:      darwin
[debug] [2019-12-25T07:48:11.932Z] Node Version:  v11.10.0
[debug] [2019-12-25T07:48:11.933Z] Time:          Wed Dec 25 2019 16:48:11 GMT+0900 (GMT+09:00)
[debug] [2019-12-25T07:48:11.933Z] ----------------------------------------------------------------------
[debug] 
[debug] [2019-12-25T07:48:11.944Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2019-12-25T07:48:11.944Z] > authorizing via signed-in user
[debug] [2019-12-25T07:48:11.944Z] [iam] checking project {project-name} for permissions ["firebase.projects.get","firebasehosting.sites.update"]
[debug] [2019-12-25T07:48:11.946Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/{project-name}:testIamPermissions  

[debug] [2019-12-25T07:48:12.909Z] <<< HTTP RESPONSE 200
[debug] [2019-12-25T07:48:12.914Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/{project-name}  
 
[debug] [2019-12-25T07:48:13.306Z] <<< HTTP RESPONSE 200
[debug] [2019-12-25T07:48:15.362Z] TypeError: Cannot read property 'wanted' of undefined
    at /Users/{user-name}/.nodebrew/node/v11.10.0/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
[error] 
[error] Error: An unexpected error has occurred.

※ Firebaseのプロジェクト名を{project-name}に、Macのユーザ名を{user-name}に置き換えてあります。

環境

$ node -v
 v11.10.0
$ npm -v
 6.10.0
$ firebase --version
 7.0.2

対応内容

ググってみると、同種のエラーの報告がいくつか存在した。対処としては、npmのバージョンアップを進めているものがほとんどだったため、私の環境でも試すことにした。

が、改善せず。。。

別の対処を探していると、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をいじってしまえと。あまりやりたくない方法だったが、他に方法が思いつかず、これを参考にすることにした。

ただ、私の環境で当該ファイルを確認したところ、参考にした投稿とは異なる内容だった。

以下のような修正を加えると、正常に動作するようになった。

- if (!options.config.has("functions")) {
+ if (!options.config.has("firebase-functions")) {

とりあえず、解決。

タイトルとURLをコピーしました