Skip to content
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

Unable to run firebase functions locally the ES6 imports are not working #152

Open
lohanidamodar opened this issue Jul 15, 2020 · 8 comments

Comments

@lohanidamodar
Copy link

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.

@TarikHuber
Copy link
Owner

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.

@TarikHuber
Copy link
Owner

Check this out. It looks like it works. We just can't use the import
https://twitter.com/tmthyrd/status/1373280164801560577

@tonprince
Copy link

Thanks for providing firebase-function-tools.

Can I use the loadFunctions with ES6? Any sample?

@TarikHuber
Copy link
Owner

Did you try it with import loadFunctions from 'firebase-function-tools'

@tonprince
Copy link

Will try again and replace exports with variable.

@TarikHuber
Copy link
Owner

@tonprince do you have any updates on this?

@tonprince
Copy link

I switched to new cloud functions 2nd gen.

@augustogiavedoni
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants