react-most-wanted
react-most-wanted copied to clipboard
Unable to run firebase functions locally the ES6 imports are not working
Hi, I am using firebase-function-tools
to write my firebase functions. However I am unable to run firebase functions on emulators locally. Imported import {functions} from 'firebase-functions'
, functions is undefined. And there are other imports that are not working too. Is there any solutions. Thank you.
Hi @lohanidamodar
The import for the functions would look like this:
import * as functions from 'firebase-functions'
For me that works when I publish the functions but I haven't tried it with the emulators. I rather have a project just for development and test everything there ;)
I hope that this can help you. Let me know if you have more issues.
Check this out. It looks like it works. We just can't use the import
https://twitter.com/tmthyrd/status/1373280164801560577
Thanks for providing firebase-function-tools.
Can I use the loadFunctions with ES6? Any sample?
Did you try it with import loadFunctions from 'firebase-function-tools'
Will try again and replace exports with variable.
@tonprince do you have any updates on this?
I switched to new cloud functions 2nd gen.
Hi there! I'm experiencing this issue as well. When trying to deploy the functions on local emulator, the follow error is thrown:
⬢ functions: Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/augustogiavedoni/-----/-----/backend/functions/node_modules/camelcase/index.js from /Users/augustogiavedoni/-----/-----/backend/functions/node_modules/firebase-function-tools/lib/load.js not supported. Instead change the require of index.js in /Users/augustogiavedoni/-----/-----/backend/functions/node_modules/firebase-function-tools/lib/load.js to a dynamic import() which is available in all CommonJS modules.
Seems to me that the problem is that firebase-function-tools
uses an outdated version of the camelcase
package (currently using v5.3.1 and latest is 7.0.1).