Can't deploy firebase cloud functions with Stripe

I'm trying to use Firebase Cloud Functions to communicate with Stripe API, and I am unable to deploy any functions, even if I'm only initializing Stripe.

This is the code:

const fun = functions.region("europe-west2");
const secretKey = functions.config().stripe.key;
const pubKey = functions.config().stripe.push;
const stripe = new Stripe(pubKey, {
  apiVersion: "2020-08-27",

export const helloWorld = fun
    .https.onRequest((request, response) => {"Hello logs!", {structuredData: true});
        "secret": secretKey,
        "pub": pubKey,
        "stripe": stripe,

I tried initializing Stripe inside the functions, but I get the same error.


firebase deploy --only functions:helloWorld

=== Deploying to '[PROJECT NAME]'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> lint
> eslint --ext .js,.ts .

Running command: npm --prefix "$RESOURCE_DIR" run build

> build
> tsc

✔  functions: Finished running predeploy script.
i  functions: ensuring required API is enabled...
i  functions: ensuring required API is enabled...
✔  functions: required API is enabled
✔  functions: required API is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (90.78 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: updating Node.js 14 function helloWorld(europe-west2)...
i  functions: cleaning up build files...
Function URL (helloWorld(europe-west2)): [URL HERE]

Functions deploy had errors with the following functions:

To try redeploying those functions, run:
    firebase deploy --only "functions:helloWorld"

To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

Is there a syntax error I'm not seeing? Am I using the library wrong? What can I do to fix this?

1 answer

  • answered 2021-10-12 16:23 Bashar Shehab

    Turns out I just needed to npm install stripe --save inside the functions folder, and not in the source folder.

    Sorry for the dumb question, I'm new to TypeScript and JavaScript.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum