firebase-tools: Nuxt3 Error - Failed to find location of Firebase Functions SDK

[REQUIRED] Environment info

firebase-tools: 11.22.0

Platform: Windows

[REQUIRED] Test case

npx firebase deploy

[REQUIRED] Steps to reproduce

The error occurs when using a nuxt v3.1.1 app in a monorepo.

First I build the app for production with npx cross-env NITRO_PRESET=firebase npm run build

Then I deploy on Firebase Hosting with npx firebase deploy

Here is my firebase.json :

{
  "functions": [
    {
      "source": ".output/server",
      "codebase": "nuxt"
    },
    {
      "source": "functions",
      "codebase": "functions",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ],
      "predeploy": [
        "npm --prefix \"$RESOURCE_DIR\" run lint"
      ]
    }
  ],
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "public": ".output/public",
    "cleanUrls": true,
    "rewrites": [{ "source": "**", "function": "server" }],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

[REQUIRED] Expected behavior

Before upgrading to firebase-tools 11.22.0, I used 11.21.0 version. I was able to deploy on Firebase Hosting (although I was facing the https://github.com/firebase/firebase-tools/issues/4952 issue and used the fix mentionned in the thread).

[REQUIRED] Actual behavior

I get following error :

Error: Failed to find location of Firebase Functions SDK. Please file a bug on Github (https://github.com/firebase/firebase-tools/).

The content of firebase-debug.log :

[debug] [2023-02-01T22:01:08.076Z] ---------------------------------------------------------------------- [debug] [2023-02-01T22:01:08.082Z] Command: C:\Program Files\nodejs\node.exe C:\Users\plsch\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy --debug flag [debug] [2023-02-01T22:01:08.084Z] CLI Version: 11.22.0 [debug] [2023-02-01T22:01:08.084Z] Platform: win32 [debug] [2023-02-01T22:01:08.084Z] Node Version: v16.16.0 [debug] [2023-02-01T22:01:08.086Z] Time: Wed Feb 01 2023 23:01:08 GMT+0100 (heure normale d’Europe centrale) [debug] [2023-02-01T22:01:08.087Z] ---------------------------------------------------------------------- [debug] [error] [error] Error: Too many arguments. Run firebase help deploy for usage instructions

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 21 (1 by maintainers)

Most upvoted comments

@rensvis Sorry, I may have been unclear. Currently there are two tooling strategies to get a Nuxt 3 app on firebase and both don’t work properly:

  1. If you do the tooling via nuxt3/nitro (as in your case), then the easiest way to deploy the app is to go to the .output/server folder and do npm install. Then you can use firebase deploy to publish the app. This solution is of course contrary to tracing by nitro and increases the package load. My fix for nitro would solve this problem though.
  2. There is a new experimental tooling strategy using the cli from firebase. Here firebase does the tooling but there are still problems for nuxt 3 because nitro does a tracing of the packages and firebase uses npm. For this I also made a pull request (https://github.com/firebase/firebase-tools/pull/5490). Your firebase.json would look like this with this tooling strategy:
{
  "hosting": {
    "site": "rens-vis-nuxt",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "cleanUrls": true
  }
}

A function for nuxt would no longer need to be entered, as this would be handled by firebase cli. In my example I have only given another function folder as an example for further firebase functions. You can now simply use the firebase cli for building the app:

  • firebase emulators:start
  • firebase deploy

However, I still ran into a few problems that I’m trying to solve in my pull request.

I hope this helps to understand a little better what the current state of nuxt3 and firebase interaction is and what solutions are currently available.

Same here.

My config

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "public": ".output/public",
    "cleanUrls": true,
    "rewrites": [
      {
        "source": "**",
        "function": "server"
      }
    ],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },
  "functions": [
    {
      "source": ".output/server",
      "codebase": "default"
    }
  ]
}

And after running firebase deploy --debug

[2023-02-04T20:24:41.052Z] Building nodejs source
[2023-02-04T20:24:41.053Z] Could not find functions.yaml. Must use http discovery

Error: Failed to find location of Firebase Functions SDK. Please file a bug on Github (https://github.com/firebase/firebase-tools/).

This is also a Nuxt 3 setup, with present Firebase.

I was able to fix this, but all I did was delete my functions directory and do a firebase init --only functions and it fixed all the issues for me. Of course, I am also using codebases format so my firebase.json looks like so:

{
  "functions": [
    {
      "source": ".output/server",
      "codebase": "nuxt",
      "runtime": "nodejs16"
    },
    {
      "source": "functions",
      "codebase": "functions",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ],
  "hosting": [
    {
      "site": "<removed>",
      "predeploy": "npm run build", // <---- I added this 
      "public": ".output/public",
      "cleanUrls": true,
      "rewrites": [
        {
          "source": "**",
          "function": "server"
        }
      ]
    }
  ]
}

This bug is a tracing error in unjs/nitro. It may be possible to fix this with a different packaging strategy on the firebase side but I don’t know about that. I have already made a fix for nuxt: https://github.com/unjs/nitro/pull/627

In addition, you can now also use the following firebase config:

{
  "functions": [{
    "source": "./functions",
    "runtime": "nodejs18",
    "codebase": "fbFunctions"
  }],
  "hosting": [
    {
      "site": "nuxt-app",
      "source": "./app",
      "cleanUrls": true,
      "rewrites": [
        {
          "source": "/any-function",
          "function": "testfunction"
        }
      ]
    }
  ]
}

If you specify the nuxt app folder under “source”, then firebase builds the app and that works fine for me.