Stripe with Remix 2.0

I'm using Stripe with Remix on CF Pages, using this configuration:
export const stripe = (stripe_key) =>
new Stripe(stripe_key, {
apiVersion: '2023-08-16',
typescript: true,
httpClient: Stripe.createFetchHttpClient(),
})
export const stripe = (stripe_key) =>
new Stripe(stripe_key, {
apiVersion: '2023-08-16',
typescript: true,
httpClient: Stripe.createFetchHttpClient(),
})
` I've tried many ways but I always get this error:
node_modules/object-inspect/util.inspect.js:1:25:
1 │ module.exports = require('util').inspect;
╵ ~~~~~~

The package "util" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
node_modules/object-inspect/util.inspect.js:1:25:
1 │ module.exports = require('util').inspect;
╵ ~~~~~~

The package "util" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
Is this related with ESM config in Remix 2.0. ? I thught Stripe was totally compatible with Workers...
7 Replies
snapo
snapo15mo ago
Hey 🙂 I was struggling with the same issue. I am still confused why Stripe actually does not work with wrangler 3.x and Remix 2.x. Try adding this to the remix.config.mjs
serverNodeBuiltinsPolyfill: {
modules: ['util'],
},
serverNodeBuiltinsPolyfill: {
modules: ['util'],
},
At least you get rid of the error. However, I have not yet conducted an end-to-end test verifying this actually works. If you try it, let me know! I am curious
rodrigo
rodrigoOP15mo ago
They might need to update it to make it work with Remix 2.0, because it's supposed to work with Workers. https://blog.cloudflare.com/announcing-stripe-support-in-workers/
The Cloudflare Blog
Announcing native support for Stripe’s JavaScript SDK in Cloudflare...
Handling payments inside your apps is crucial to building a business online. For many developers, the leading choice for handling payments is Stripe.
snapo
snapo15mo ago
Yes, there is also bunch of other compativility isssues. To list some: - util - crypto - buffer When bumping from Wrangler 2.x to 3.x and from Remix 1.9 to 2.x, bunch of libraries that used to work are now throwing errors related to nodejs_compat. I can't just yet really pinpoint down what went wrong, but something is off for sure 🤔
rodrigo
rodrigoOP15mo ago
Should we open a issue on Stripe github to track down all these bugs?
mehmetcan
mehmetcan15mo ago
@snapo thank you its work for me
snapo
snapo15mo ago
I am pretty sure this is not Stripe related but more some remix - cloudflare internals. My sophisticated guess would be cloudflare or just wrangler
mehmetcan
mehmetcan15mo ago
GitHub
Stripping of "node:" prefix on node imports like 'node:util' breaks...
What version of Remix are you using? 1.14.3 Are all your remix dependencies & dev-dependencies using the same version? Yes Steps to Reproduce Have import * as Util from 'node:util'; con...
Want results from more Discord servers?
Add your server