#Stripe JS - Vite config issue - ssr.noExternal

6 messages · Page 1 of 1 (latest)

hollow wigeon
#

Hello!
Trying to get Stripe integration going into these 2 apps, and got it working locally, but when I run the build I get this error:

Cannot bundle Node.js built-in "events" imported from "node_modules/stripe/lib/stripe.js". Consider disabling ssr.noExternal or remove the built-in dependency.

I looked on Discord and found some other similar requests, but none of their solves has worked so far.

Anyone familiar with and can help?
Running the Stripe Node JS as a server side API in an onPost
https://github.com/stripe/stripe-node

GitHub

Node.js library for the Stripe API. . Contribute to stripe/stripe-node development by creating an account on GitHub.

#

I'm not great with vite config or regex, so here is what I've tried;
noExternal: [/stripe.js$/, /node_modules\/stripe\/lib\/stripe.js$/]

  • every combo of both, or only 1

noExternal: true

So far still failing build.

#

Tried removing defineConfig and returning the object, makes no difference (didn't think it would, but will try all the things)

hollow wigeon
#

Seems like not using the Stripe SDK does work, so using the API directly with fetch is the workaround, but would love to figure this out so I can use their SDK instead

hollow wigeon
#

IF anyone else has this issue - I built a Cloudflare worker since they now support Stripe and am running that as a wrapper API for my calls, made a little RESTful API out of it, which is fun.

steep sinew
#

Have you tried loading the SDK using a script tage <script async src="https://js.stripe.com/v3/"></script> rather than importing it into the bundle?