zach wilcox
zach wilcox

Reputation: 75

error creating stripe customer on create iOS and firebase

I am trying to create a stripe customer when the user creates an account on my IOS app. When I run the command firebase deploy --only functions All of my functions crash. but when I delete

const logging = require('@google-cloud/logging');
const stripe = require('stripe')(functions.config().stripe.token);
const currency = functions.config().stripe.currency || 'USD';



  exports.createStripeCustomer = functions.auth.user().onCreate((user) => {
  return stripe.customers.create({
  email: user.email,
  }).then((customer) => {
    return admin.database().ref(`/stripe_customers/${user.uid}/customer_id`).set(customer.id);
  });
});

I am receiving the error

Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs

After going through my code I have narrowed it done to these lines. When I delete the three const, I receive the same error. If I delete the export and keep const, the same thing. My functions only push when I delete all of this. Is there something I am missing? I have seen similar questions and the answers on here have resembled the code I have so I am confused. I am checking my logs and it is not descriptive it is just repeating the same message.

The log messages I am receiving in firebase functions is,

Detailed stack trace: Error: Cannot find module '@google-cloud/logging'

Upvotes: 0

Views: 137

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

If you want to use a module, you have to install it first before you deploy. From your functions folder, where the original package.json exists:

npm install @google-cloud/logging

Upvotes: 1

Related Questions