-
Notifications
You must be signed in to change notification settings - Fork 928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuxt3 Error - Failed to find location of Firebase Functions SDK #5482
Comments
Same here. My config
And after running firebase deploy --debug
This is also a Nuxt 3 setup, with present Firebase. |
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: 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. |
I'm having the same problem. Also Nuxt 3.
|
@rensvis Sorry, I may have been unclear.
{
"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.
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. |
I am having the same problem, but also when I ran
Anyone have any ideas? My app is offline now because of this and can't deploy Nuxt server function to firebase! |
@dosstx const fs = require('fs-extra')
const path = require('path')
const serverDir = __dirname + '/.output/server'
const functionDir = path.join(serverDir, 'node_modules', 'firebase-functions')
const nodeModulesDir = path.join(__dirname ,'node_modules')
if (fs.existsSync(functionDir)) {
if (nodeModulesDir) {
['firebase-functions', 'semver'].map(name => fs.copySync(path.join(nodeModulesDir, name), path.join(serverDir, 'node_modules', name)))
if (!fs.existsSync(path.join(serverDir, 'node_modules', '.bin'))) {
fs.mkdirSync(path.join(serverDir, 'node_modules', '.bin'))
fs.symlinkSync(path.join(functionDir, 'lib', 'bin', 'firebase-functions.js'), path.join(serverDir, 'node_modules', '.bin', 'firebase-functions'), 'file')
}
}
} Simply save this code in the root directory as a deploy.js file and add the deploy script to your firebase.json file: {
"functions": [{
"source": ".output/server",
"predeploy": "node ./deploy.js"
}],
"hosting": [{
"site": "your-site",
"public": "./app/.output/public",
"cleanUrls": true,
"rewrites": [
{
"source": "**",
"function": "server"
}
]
}]
} So i was able to work around the tracing bug and maybe it fixes your bug as well. |
Thank you! Will give it a shot! @DevJoghurt |
I was able to fix this, but all I did was delete my functions directory and do a
|
This should now work with the source option: {
"functions": [
{
"source": "functions",
"codebase": "functions",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
]
}
],
"hosting": [
{
"site": "<removed>",
"source": "."
}
]
} |
@jamesdaniels Could you please give more insight about your fix ? I don't understand what |
@dosstx's sample worked for me; however if I move the Nuxt application down from the root directory into a So if my path is like this: |
@desk-pro The https://firebase.google.com/docs/hosting/frameworks/frameworks-overview The way I can get it to work is the following:
To answer your question, the NOTE: From my own experimentation, it doesn't seem to support using any nested directory like I have a sample repo here: https://github.com/CharlieDigital/nuxt3-firebase And the app running here:
Still working out some kinks; hoping the documentation gets updated. |
How did you go with this? I noticed when doing this with VueFire auth you get this error on build: [nuxt] [request error] [unhandled] [500] Failed to parse service account json file: Error: Service account object must contain a string "project_id" property. |
The VueFire error is because it's trying to run the Firebase client on the server and fails. The gist of the workaround for this error is to isolate the Firebase dependent code to only run on the client. You can use a variety of techniques for this. The easiest: if the page doesn't need server rendering, then set |
But I'm checking auth and fetching Firestore results server side? I need this for key landing pages for SEO. The build currently works when running the buiild normally and deploying it without Firebase's new experimental hosting feature. Although you mentioned when you nested the project you have issues (ie /nuxt-app), I'm wondering If this is the issue as I'm doing the same in a monorepo |
On the server side, you use the Admin SDK. But the problem is that if you are running your code with SSR and it's loading the client SDKs as well, you'll get the error. So in your SSR routes, you need to isolate the client SDKs from the server SDKs and ensure that the SSR routes don't load the client SDKs. |
Hmm ok interesting.thinking into it, most of the calls are being made with Vuefire. I'll dig into it and see how I go. Thank you.Quick question, why is it that the build and deploy to Firebase works without using Firebase's new hosting feature?On 25 Sept 2023 7:14 am, Charles Chen ***@***.***> wrote:
On the server side, you use the Admin SDK. But the problem is that if you are running your code with SSR and it's loading the client SDKs as well, you'll get the error.
So in your SSR routes, you need to isolate the client SDKs from the server SDKs and ensure that the SSR routes don't load the client SDKs.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
If you look carefully the output of the build process, the new Firebase Hosting Web Frameworks is effectively generating a Function that is very similar to what the Nuxt Firebase build preset does. They are somewhat interchangeable. |
Any solution? i have tried some answers above but still fail? My last attempt was performing
it created new folder functions but when doing deploy still return error. Console error said,
|
@superdiazzz Can you verify that there is actually output at |
I think i was in wrong way, so i tried another way with this tutorial. I get back from beginning and make my firebase.json below:
i change my nuxt.config.ts
then run this scrip in package.json
But, sadly it failed with no clue ;( |
[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
:[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 #4952 issue and used the fix mentionned in the thread).
[REQUIRED] Actual behavior
I get following error :
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
The text was updated successfully, but these errors were encountered: