FirebaseのFunctionsで「TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string」のエラーが出て対処したメモ
状況
firebase deployでFunctionsをデプロイしようとするとエラーが発生
> firebase deploy
Error: An unexpected error has occurred.
firebase-debug.logを見てみる
[debug] [2020-11-10T02:57:36.389Z] ----------------------------------------------------------------------
[debug] [2020-11-10T02:57:36.391Z] Command: /usr/local/Cellar/node/15.1.0/bin/node /usr/local/bin/firebase deploy
[debug] [2020-11-10T02:57:36.391Z] CLI Version: 8.15.1
[debug] [2020-11-10T02:57:36.391Z] Platform: darwin
[debug] [2020-11-10T02:57:36.391Z] Node Version: v15.1.0
[debug] [2020-11-10T02:57:36.392Z] Time: Tue Nov 10 2020 11:57:36 GMT+0900 (Japan Standard Time)
[debug] [2020-11-10T02:57:36.392Z] ----------------------------------------------------------------------
[debug] [2020-11-10T02:57:36.392Z]
[debug] [2020-11-10T02:57:36.406Z] > 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] [2020-11-10T02:57:36.407Z] > authorizing via signed-in user
[debug] [2020-11-10T02:57:36.407Z] [iam] checking project *****-***-***** for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2020-11-10T02:57:36.409Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-11-10T02:57:36.409Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
<request body omitted>
[debug] [2020-11-10T02:57:36.574Z] <<< HTTP RESPONSE 200 {"pragma":"no-cache","date":"Tue, 10 Nov 2020 02:57:36 GMT","cache-control":"no-cache, no-store, max-age=0, must-revalidate","expires":"Mon, 01 Jan 1990 00:00:00 GMT","content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[debug] [2020-11-10T02:57:36.598Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/*****-***-*****:testIamPermissions
{"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]}
[debug] [2020-11-10T02:57:36.960Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=UTF-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Tue, 10 Nov 2020 02:57:36 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","server-timing":"gfet4t7; dur=135","alt-svc":"h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[debug] [2020-11-10T02:57:36.961Z] >>> HTTP REQUEST POST https://iam.googleapis.com/v1/projects/*****-***-*****/serviceAccounts/*****-***-*****@appspot.gserviceaccount.com:testIamPermissions
{"permissions":["iam.serviceAccounts.actAs"]}
[debug] [2020-11-10T02:57:37.490Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=UTF-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Tue, 10 Nov 2020 02:57:37 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[debug] [2020-11-10T02:57:37.620Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:259:15)
at validateString (node:internal/validators:123:11)
at Object.join (node:path:1039:7)
at Object.checkFunctionsSDKVersion [as fn] (/usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:34:28)
at Command.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/command.js:169:30)
at Generator.next (<anonymous>)
at fulfilled (/usr/local/lib/node_modules/firebase-tools/lib/command.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
[error]
[error] Error: An unexpected error has occurred.
ここでエラーになっているものの、ネットで調べてもそれっぽい情報が出てこず・・
[debug] [2020-11-10T02:57:37.620Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
結論
後々分かるとしょうもないミスだったのですが、firebase initして作ったデフォルトのフォルダ名(functions)を変更すると、参照するディレクトリが無くて発生するようでした
functionsフォルダと同じ階層にfirebase.jsonも作られていて、こちらの中身をいじると「functions」から名前変更しても大丈夫なようですが、その辺りの調整が必要みたいです..
(結局は素直にfunctionsに戻しました)
Author And Source
この問題について(FirebaseのFunctionsで「TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string」のエラーが出て対処したメモ), 我々は、より多くの情報をここで見つけました https://qiita.com/hisw/items/d420a5721c504946450d著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .