Hi, I am not sure what's going on but after upgrading Angular 9->10 I am getting errors deploying to Firebase Hosting.
I filed an issue over at the Angular repo but got the sense that it could be an issue with Firebase-tools.
I've upgraded to latest Firebase-tools but still getting errors when trying to deploy.
Hoping someone can give me a pointer to what's wrong. I am having this issues on multiple different projects.
Firebase-debug.log doesn't provide much helpful information.
.firebaserc:
{
"projects": {
"default": "fabrik-menu-poc",
"test": "fabrik-menu-poc"
}
}
Running firebase deploy --project test gives me
firebase deploy --only hosting --project test
Error: An unexpected error has occurred.
Having trouble? Try again or contact support with contents of firebase-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] deploy:test: `firebase deploy --only hosting --project test`
npm ERR! Exit status 2
Error log:
silly lifecycle [email protected]~deploy:test: Args: [ '-c', 'firebase deploy --only hosting --project test' ]
11 silly lifecycle [email protected]~deploy:test: Returned: code: 2 signal: null
12 info lifecycle [email protected]~deploy:test: Failed to exec deploy:test script
13 verbose stack Error: [email protected] deploy:test: `firebase deploy --only hosting --project test`
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (/Users/lrj/.nvm/versions/node/v12.13.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess.<anonymous> (/Users/lrj/.nvm/versions/node/v12.13.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/lrj/project/mother-qorder/admin
16 verbose Darwin 19.5.0
17 verbose argv "/Users/lrj/.nvm/versions/node/v12.13.1/bin/node" "/Users/lrj/.nvm/versions/node/v12.13.1/bin/npm" "run" "deploy:test"
18 verbose node v12.13.1
19 verbose npm v6.12.1
20 error code ELIFECYCLE
21 error errno 2
22 error [email protected] deploy:test: `firebase deploy --only hosting --project test`
22 error Exit status 2
23 error Failed at the [email protected] deploy:test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]
[error] Error: An unexpected error has occurred.
[debug] [2020-06-28T12:47:49.194Z] ----------------------------------------------------------------------
[debug] [2020-06-28T12:47:49.196Z] Command: /Users/lrj/.nvm/versions/node/v12.13.1/bin/node /Users/lrj/project/mother-qorder/admin/node_modules/.bin/firebase deploy --only hosting --project test
[debug] [2020-06-28T12:47:49.196Z] CLI Version: 8.4.3
[debug] [2020-06-28T12:47:49.196Z] Platform: darwin
[debug] [2020-06-28T12:47:49.196Z] Node Version: v12.13.1
[debug] [2020-06-28T12:47:49.197Z] Time: Sun Jun 28 2020 14:47:49 GMT+0200 (Central European Summer Time)
[debug] [2020-06-28T12:47:49.197Z] ----------------------------------------------------------------------
[debug] [2020-06-28T12:47:49.197Z]
[debug] [2020-06-28T12:47:49.207Z] > 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-06-28T12:47:49.207Z] > authorizing via signed-in user
[debug] [2020-06-28T12:47:49.207Z] [iam] checking project fabrik-menu-poc for permissions ["firebase.projects.get","firebasehosting.sites.update"]
[debug] [2020-06-28T12:47:49.210Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/fabrik-menu-poc:testIamPermissions
{"permissions":["firebase.projects.get","firebasehosting.sites.update"]}
[debug] [2020-06-28T12:47:50.114Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=UTF-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Sun, 28 Jun 2020 12:47:49 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","server-timing":"gfet4t7; dur=730","alt-svc":"h3-27=\":443\"; ma=2592000,h3-25=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q050=\":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-06-28T12:47:50.116Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/fabrik-menu-poc
[debug] [2020-06-28T12:47:51.237Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=UTF-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Sun, 28 Jun 2020 12:47:51 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-27=\":443\"; ma=2592000,h3-25=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q050=\":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-06-28T12:47:51.387Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:112:11)
at Object.join (path.js:1040:7)
at Object.checkFunctionsSDKVersion [as fn] (/Users/lrj/project/mother-qorder/admin/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:33:28)
at Command.<anonymous> (/Users/lrj/project/mother-qorder/admin/node_modules/firebase-tools/lib/command.js:159:30)
at Generator.next (<anonymous>)
at fulfilled (/Users/lrj/project/mother-qorder/admin/node_modules/firebase-tools/lib/command.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
[error]
[error] Error: An unexpected error has occurred.
Firebase-tools version:
firebase-tools": "^8.4.3"
This issue does not seem to follow the issue template. Make sure you provide all the required information.
The "issue" has been resolved.
Turned out I had Firebase-tools installed both globally and locally (doh!).. and as I only upgraded the locally installed, it never really worked..
Feeling pretty stupid now, sorry for taking your time :)
Reopening again, it's still an issue, .. weirdest thing I've ever seen.
Firebase-tools: 8.4.3
Same issue
@spock123 if the error occurred when upgrading Angular versions that sounds like it's a bug with Angular or in your own code. However there's one thing to investigate:
The error message you're seeing here:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
Points to a possible issue in your firebase.json. Could you show the contents of that file?
@samtstern I figure about the same but cannot see any changes in our configuration files.
The .firebaserc is unchanged:
{
"projects": {
"default": "fabrik-menu-poc",
"test": "fabrik-menu-poc"
}
}
firebase.json:
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/images/:products*",
"destination": "https://firebasestorage.googleapis.com/v0/b/ngpwastore.appspot.com/o/images/:products"
},
{
"source": "/da/**",
"destination": "/da/index.html"
},
{
"source": "/en/**",
"destination": "/en/index.html"
},
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/**",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
}
]
},
{
"source": "**/(ngsw-worker.js|ngsw.json)",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
}
]
},
{
"source": "**/*.@(jpg|woff|woff2|eot|webm|svg|jpeg|gif|png|js|css|ttf|webp)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=31536000"
}
]
}
]
},
"functions": {
"predeploy": "npm --prefix \"$RESOURCE_DIR\" run build"
}
}
@samtstern I think I have figured out the issue:
Notice in the firebase.json that there is a "functions" property.
We are not using functions any longer, but if I remove that section, it seems to be working.
When the section intact, the following command errors:
firebase deploy --only hosting --project test
But if I remove the "functions" property in firebase.json it works.
Strangely I did not have this issue with firebase-tools 7.x and the Angular 9 build.
@spock123 yep that's it! What's happening is that adding functions to firebase.json implies that you're using Cloud Functions. We have a check (checkFirebaseSDKVersion.js) which tries to make sure your functions code is deployable but you don't have any functions code so it errored when trying to read the default path.
@laurenzlong it looks like you recently refactored checkFirebaseSDKVersion. Can you investigate why it's running at all for a hosting deploy?
@samtstern Thank you for leading me on the right path (firebase.json)..
@samtstern checkFirebaseSDKVersion runs for all deploys (since the intention is that there may be other SDKs for other products that we'd want to check the version of, although right now it's just for functions.) I think the fix is that it should also be checking the --only flag to not check functions SDK if it's functions are being deployed. I don't think I'll have time to address this soon, but would definitely be happy to review PRs.
The workaround, as you've both discovered, is to remove "functions" from firebase.json if functions code has been removed from the project directory.
Thank you @laurenzlong , yes the issue is easily worked around so I'm not sure it's worth keeping this issue open. If people google it in the future with the same setup as me, they'll hopefully stumble upon this. Cheers
Ran into this issue when trying to deploy a functions project. I had made some changes to the directory structure of my project over a period of time which lead to the firebase.json file being in the ./functions folder. This is apparently problematic because the Firebase CLI is expecting a ./functions folder in the same directory as the firebase.json file, unless you specify a source property in the firebase.json file. In my case, adjusting the firebase.json file to include the following, solved the problem:
firebase.json:
{
"functions": {
"source": ".",
...
},
...
}