Home
Support Forums

Conflict between firebase functions and netlify functions

Hi!

address: babillard.netlify.app

My app uses firebase (auth, firestore, storage, functions) I only started using functions not long ago and since then, I get an error when deploying new updates.

There seems to be a conflict etween firebase functions and netlify functions.
I pasted the log. I can see that some solutions are proposed in there but I don’t undersatnd exactly what they mean. I’m still a newbie, so id someone could help me out here, it would be awesome.

Thanks in advance!
Eric

9:06:39 PM: Build ready to start
9:06:41 PM: build-image version: 8925038cf853b22d6397cdcb9904ac88b66bb383 (focal)
9:06:41 PM: build-image tag: v4.5.0
9:06:41 PM: buildbot version: fa6cc7f6d011b8899be97010416c5b5974d37673
9:06:41 PM: Fetching cached dependencies
9:06:41 PM: Starting to download cache of 185.1MB
9:06:42 PM: Finished downloading cache in 1.524865464s
9:06:42 PM: Starting to extract cache
9:06:49 PM: Finished extracting cache in 6.485649344s
9:06:49 PM: Finished fetching cache in 8.064123914s
9:06:49 PM: Starting to prepare the repo for build
9:06:49 PM: Preparing Git Reference refs/heads/master
9:06:49 PM: Parsing package.json dependencies
9:06:50 PM: Starting build script
9:06:50 PM: Installing dependencies
9:06:50 PM: Python version set to 2.7
9:06:50 PM: Started restoring cached node version
9:06:53 PM: Finished restoring cached node version
9:06:54 PM: v16.13.0 is already installed.
9:06:54 PM: Now using node v16.13.0 (npm v8.1.0)
9:06:54 PM: Started restoring cached build plugins
9:06:54 PM: Finished restoring cached build plugins
9:06:54 PM: Attempting ruby version 2.7.2, read from environment
9:06:56 PM: Using ruby version 2.7.2
9:06:56 PM: Using PHP version 8.0
9:06:56 PM: Started restoring cached node modules
9:06:56 PM: Finished restoring cached node modules
9:06:57 PM: Started restoring cached go cache
9:06:57 PM: Finished restoring cached go cache
9:06:57 PM: go version go1.16.5 linux/amd64
9:06:57 PM: go version go1.16.5 linux/amd64
9:06:57 PM: Installing missing commands
9:06:57 PM: Verify run directory
9:06:58 PM: ​
9:06:58 PM: ────────────────────────────────────────────────────────────────
9:06:58 PM:   Netlify Build                                                 
9:06:58 PM: ────────────────────────────────────────────────────────────────
9:06:58 PM: ​
9:06:58 PM: ❯ Version
9:06:58 PM:   @netlify/build 18.25.2
9:06:58 PM: ​
9:06:58 PM: ❯ Flags
9:06:58 PM:   baseRelDir: true
9:06:58 PM:   buildId: 619bf84ff9db387da6fa52a3
9:06:58 PM:   deployId: 619bf84ff9db387da6fa52a5
9:06:58 PM: ​
9:06:58 PM: ❯ Current directory
9:06:58 PM:   /opt/build/repo
9:06:58 PM: ​
9:06:58 PM: ❯ Config file
9:06:58 PM:   /opt/build/repo/netlify.toml
9:06:58 PM: ​
9:06:58 PM: ❯ Context
9:06:58 PM:   production
9:06:58 PM: ​
9:06:58 PM: ────────────────────────────────────────────────────────────────
9:06:58 PM:   1. Build command from Netlify app                             
9:06:58 PM: ────────────────────────────────────────────────────────────────
9:06:58 PM: ​
9:06:58 PM: $ npm run build
9:06:59 PM: > babillard@0.1.0 build
9:06:59 PM: > vue-cli-service build
9:07:00 PM: -  Building for production...
9:07:17 PM:  WARNING  Compiled with 3 warnings8:07:17 PM
9:07:17 PM:  warning 
9:07:17 PM: asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
9:07:17 PM: This can impact web performance.
9:07:17 PM: Assets:
9:07:17 PM:   js/chunk-vendors.75c0d639.js (804 KiB)
9:07:17 PM:  warning 
9:07:17 PM: entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
9:07:17 PM: Entrypoints:
9:07:17 PM:   app (872 KiB)
9:07:17 PM:       js/chunk-vendors.75c0d639.js
9:07:17 PM:       css/app.0fa18cba.css
9:07:17 PM:       js/app.acd97246.js
9:07:17 PM:  warning 
9:07:17 PM: webpack performance recommendations:
9:07:17 PM: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
9:07:17 PM: For more info visit https://webpack.js.org/guides/code-splitting/
9:07:17 PM:   File                                 Size               Gzipped
9:07:17 PM:   dist/js/chunk-vendors.75c0d639.js    803.73 KiB         197.08 KiB
9:07:17 PM:   dist/js/app.acd97246.js              58.48 KiB          14.60 KiB
9:07:17 PM:   dist/css/app.0fa18cba.css            9.43 KiB           2.54 KiB
9:07:17 PM:   Images and other types of assets omitted.
9:07:17 PM:  DONE  Build complete. The dist directory is ready to be deployed.
9:07:17 PM:  INFO  Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html
9:07:18 PM: ​
9:07:18 PM: (build.command completed in 19.1s)
9:07:18 PM: ​
9:07:18 PM: ────────────────────────────────────────────────────────────────
9:07:18 PM:   2. Functions bundling                                         
9:07:18 PM: ────────────────────────────────────────────────────────────────
9:07:18 PM: ​
9:07:18 PM: Packaging Functions from functions directory:
9:07:18 PM:  - index.js
9:07:18 PM: ​
9:07:18 PM: ​
9:07:18 PM: ────────────────────────────────────────────────────────────────
9:07:18 PM:   Dependencies installation error                               
9:07:18 PM: ────────────────────────────────────────────────────────────────
9:07:18 PM: ​
9:07:18 PM:   Error message
9:07:18 PM:   A Netlify Function is using "firebase-functions" but that dependency has not been installed yet.
9:07:18 PM: ​
9:07:18 PM:   By default, dependencies inside a Netlify Function's "package.json" are not automatically installed.
  There are several ways to fix this problem:
9:07:18 PM:     - Removing your Function's "package.json" and adding the dependencies to the project's top-level "package.json" instead. This is the fastest and safest solution.
9:07:18 PM:     - Running "npm install" or "yarn" inside your Netlify Function in your build command.
9:07:18 PM:     - Adding the following plugin to your "netlify.toml":
9:07:18 PM: ​
9:07:18 PM:   [[plugins]]
9:07:18 PM:   package = "@netlify/plugin-functions-install-core"
9:07:18 PM: ​​
9:07:18 PM:   In file "/opt/build/repo/functions/index.js"
9:07:18 PM:   Cannot find module 'firebase-functions'
9:07:18 PM:   Require stack:
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/zisi/resolve.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/zisi/traverse.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/src_files.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/index.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/index.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/index.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/index.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/main.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins_core/functions/index.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/build/src/steps/get.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/build/src/core/main.js
9:07:18 PM:   - /opt/buildhome/node-deps/node_modules/@netlify/build/src/core/bin.js
9:07:18 PM: ​
9:07:18 PM:   Resolved config
9:07:18 PM:   build:
9:07:18 PM:     command: npm run build
9:07:18 PM:     commandOrigin: ui
9:07:18 PM:     publish: /opt/build/repo/dist
9:07:18 PM:     publishOrigin: ui
9:07:18 PM:   functionsDirectory: /opt/build/repo/functions
9:07:18 PM:   redirects:
9:07:18 PM:     - from: /*
      status: 200
      to: /index.html
  redirectsOrigin: config
Caching artifacts
9:07:18 PM: Started saving node modules
9:07:18 PM: Finished saving node modules
9:07:18 PM: Started saving build plugins
9:07:18 PM: Finished saving build plugins
9:07:18 PM: Started saving pip cache
9:07:18 PM: Finished saving pip cache
9:07:18 PM: Started saving emacs cask dependencies
9:07:18 PM: Finished saving emacs cask dependencies
9:07:18 PM: Started saving maven dependencies
9:07:18 PM: Finished saving maven dependencies
9:07:18 PM: Started saving boot dependencies
9:07:18 PM: Finished saving boot dependencies
9:07:18 PM: Started saving rust rustup cache
9:07:18 PM: Finished saving rust rustup cache
9:07:18 PM: Started saving go dependencies
9:07:18 PM: Finished saving go dependencies
9:07:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:07:18 PM: Creating deploy upload records
9:07:18 PM: Failing build: Failed to build site
9:07:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
9:07:18 PM: Finished processing build request in 37.737802887s

Hey there, @Posoroko :wave:

Thanks so much for reaching out! All questions and problems are welcome here, no matter your experience level :slight_smile:

Can you share your project repo with us? This will help us see your set-up in better detail so we can walk through some suggestions.

Hi! Thank you for your answer and your kindness!

here is the repo:

The log proposes this:

Removing your Function’s “package.json” and adding the dependencies to the project’s top-level “package.json” instead.

I understand what it means, but I’m afraid to get mixed up…

thanks for your help!!

Hi @Posoroko,

I’d like to confirm. Are you planning to host the file in the functions directory on Netlify Functions or Firebase Functions?

I’m confused as I don’t see a real point in connecting to Firebase Functions from within Netlify Functions.

Thanks for your help!

so. I planned on using the firebase functions. I never tried using them from within de Netlify functions. So if I am, I don’t know why. I just initiated the firebase functions in my vueJs project and pushed to github.

what should I do?

That clears some stuff. Try clearing the functions directory from here: Netlify App.

At this point, Netlify thinks you’re having Netlify Functions in that folder.

So either try renaming the folder or remove that setting shared above.

There seems to be something I don’t understand. Can I actualy use the firebase functions when deploying with netlify? Or should I use netlify functions instead?
I changed the name of the functions forlder (in the site setting) to netlify-functions. So now it’s looking for it , but idoesn’t exist. So thebild manage to go through, but the firebase functions are not working.
It works fine on my local host, but not on the live version.

what do you mean by ‘clearing the directory’? Empty it or delete it?

Sorry for being such a noob!

Yeah definitely.

I believe you might have to deploy those on Firebase, correct? Have you set that up correctly?

I simply meant to remove the setting, like make the text field blank. But you’ve used a different folder name which works too.

I believe you might have to deploy those on Firebase, correct? Have you set that up correctly?

I think I 've set up things corectly in Firebase because everything work fine when the app is running on my local developement server.

So what’s the problem you’re seeing exactly?

The problem is that the functions don’t work when the app is deployed to netlify. Because netlify functions try to take over and say that it’s impossible because of firebase.

Netlify won’t automatically “take over” the functions. If you can show the problem with a live example, screenshots, screen recordings, it can help.

Thanks again for your help!
I don’t know what to share else…

I have a folder called ‘functions’ where my functions are. When I deploy to netlify, i get this error message:

 A Netlify Function is using "firebase-functions" but that dependency has not been installed yet.

Hey @Posoroko ,

It looks like you still need to clear the functions directory from the Netlify App as Hrishikesh mentioned.

To do so, go to your functions directory and click on ‘Edit settings’

Then delete ‘functions’ from the input box and Save

Hope this helps! Let us know how it goes :slightly_smiling_face: