invertase / stripe-firebase-extensions

Repository of Firebase Extensions built by Stripe.
https://firebase.google.com/products/extensions
Apache License 2.0
438 stars 172 forks source link

Cannot import @stripe/firestore-stripe-payments in firebase functions #550

Closed IM-001 closed 1 year ago

IM-001 commented 1 year ago

Bug report

Describe the bug

I am surely doing something wrong, but after days of trying I simply cannot import this npm package in my firebase function local installation. The npm package installs fine, I see it in my node_modules folder. But whatever I do with my firebase function index.js, I simply cannot make this line work (it's the only code in my function after isolating it):

Case 1: const { getStripePayments } = require("@stripe/firestore-stripe-payments"); OR Case 2: import { createCheckoutSession } from "@stripe/firestore-stripe-payments";

I think these lines of the emulators debug log are referring to the problem:

Got response code 400; body Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module shutdown requested via /__/quitquitquit

!! functions: Failed to load function definition from source: FirebaseError: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error"}}

Finally, I can run other functions in my firebase function index.js, but this package is the only one causing issues.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Expected behavior

should be able to import the package, however I cannot seem to be able to import it, tried different ways to import

System information

Thanks for your help, I have tried for a couple of days to simply import and use this package sdk and I am thinking of starting my firebase project from scratch because of this.

CleverProgrammer commented 1 year ago

+1 yup I am having a similar error.

SyntaxError: Unexpected token 'export'

IM-001 commented 1 year ago

FYI I managed to use the extension without this SDK package. Would have loved just a hello from Invertase though.. Too late.