11

After initiating my firebase app with

firebase init

I tried to deploy it with

firebase deploy

but I get this error

    === Deploying to 'fugis-auto-services-website'...

i  deploying database, storage, functions, hosting

Error: An unexpected error has occurred.

So I looked at the firebase-debug.log and this is what it says

Tue May 01 2018 19:52:19 GMT-0500 (CDT)
[debug] [2018-05-02T00:52:19.967Z] <<< HTTP RESPONSE 200
[info] 
[info] === Deploying to 'fugis-auto-services-website'...
[info] 
[info] i  deploying database, storage, functions, hosting
[debug] [2018-05-02T00:52:20.266Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.join (path.js:1157:7)
    at Config.path (/Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/config.js:166:37)
    at /Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/deploy/lifecycleHooks.js:68:38
    at _chain (/Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/deploy/index.js:26:38)
    at /Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/deploy/index.js:29:14
    at process._tickCallback (internal/process/next_tick.js:178:7)
[error] 
[error] Error: An unexpected error has occurred.

I'm not sure how to proceed.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Vanessa Flores
  • 115
  • 1
  • 6

6 Answers6

4

Too late to answer but might help someone in future, I had the same issue, i added the public folder as mentioned by @Gleb and inside your firebase.json you need to specify the public folder as well, like so:

{
"hosting": {
"public": "public",
"rewrites": [
  {
    "source": "**",
    "function": "helloWorld"
  }
]
}
}
Deo
  • 59
  • 6
  • 1
    Thanks for this! It seems the "public" argument is required for hosting to deploy. Note that you also must have an actual folder created, even though it can be empty. – Nick Farina Sep 29 '19 at 18:44
  • 1
    any ideas why get this error when deploying this: https://github.com/QuantumInformation/svelte-fullstack-starter/blob/master/firebase.json#L11 **The "path" argument must be of type string. Received type undefined at validateString (internal/validators.js:125:11)** – Nikos Dec 31 '19 at 14:23
  • Seems to be true that we need public entry in the hosting object. If thats the case any way to only have cloud function rewrite alone? – Ayyappa Feb 29 '20 at 15:05
3

I was able to fix this by re-initializing firebase functions:

firebase init functions

You might want to first update your firebase-tools:

npm install -g firebase-tools

and backup your existing functions directory.

Justin
  • 300
  • 3
  • 11
  • didn't know init can be done separately for functions, firestore etc. `firebase init functions` ran the routine and fixed it for me – Fakeer Jan 28 '20 at 03:44
3

Had same issue as i use hosting part just to setup headers, public property is necessary! If you not define it you would have this issue

Gleb Dolzikov
  • 776
  • 8
  • 13
0

My problem ended up being that I updated my macOS to High Sierra 10.13.4 and that somehow screwed up my paths for nvm. I had to update nvm and I reinstalled Firebase and now things seem to be working.

Vanessa Flores
  • 115
  • 1
  • 6
0

I was facing the same problem so after debugging for 2 hours I solved the problem by downgrading npm-conf to 1.1.0 with the command npm install npm-conf@1.1.0

0

I was using a firestore callback like onCreate or onUpdate without passing the actual document path.

functions.firestore
.document()
.onCreate()

Just turn it into

functions.firestore
.document('collection/doc')
.onCreate()
Alejov
  • 464
  • 6
  • 14