環境:
- Mac macOS Mojave 10.14.6
- Node version 14.15.1
- npm version 6.14.8
- firebase cli version 9.2.2
事象
久々に触ったreactアプリを、以前と同様にfirebaseに対してdeployしたかったのでターミナルで
command
~/workspace/admin #firebase deploy --only hosting
とタイプしたところ、以下のエラーが発生
log
Error: An unexpected error has occurred.
Having trouble? Try again or contact support with contents of firebase-debug.log
firebase-debug.log を確認してみる
firebase-debug.log
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
こちらとほぼ同じ内容でした https://github.com/firebase/firebase-tools/issues/1915
このエラーのため、firebaseに対してデプロイが出来ない状況でした。
解決策
firebase init でfirebaseの初期設定をもう一度行うことで解決しました。
エラー文でgoogle検索して様々な解決方法(firebase.json内のfunctionsキーを作成しなければいけない、各種ツールのアップデート&ダウングレード等)が出てきたのですが、結局既存のfirebase.jsonを別名保存して、新たにfirebase init し直す事で解決しました。
command
~/workspace/admin #firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/Users/xxx/workspace/admin
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. Hosting: Configure and
deploy Firebase Hosting sites
=== 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: zzz
i Using project zzz
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? build
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
? File build/index.html already exists. Overwrite? No
i Skipping write of build/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
✔ Firebase initialization complete!