Callombert
Callombert

Reputation: 1099

Stripe - ReferenceError: require is not defined

import 'stripe';

I can't seem to import server side stripe.js npm package into a Lit-HTML PWA.

I get:

ReferenceError: require is not defined

If I try:

import {Stripe} from 'stripe';

The requested module '../../../node_modules/stripe/lib/stripe.js' does not provide an export named 'Stripe'

I'm learning vanilla JS so not sure what I'm doing wrong.

Upvotes: 0

Views: 532

Answers (1)

floatingLomas
floatingLomas

Reputation: 8747

stripe-node is for server-side use, not for use in the client. You'll want to use Elements or Checkout to collect card details, etc and then user stripe-node - or one of the other libraries - server-side to handle those parts.

Upvotes: 1

Related Questions