#Stripe with Remix 2.0

8 messages · Page 1 of 1 (latest)

sleek juniper
#

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(),
    })

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.

Is this related with ESM config in Remix 2.0. ? I thught Stripe was totally compatible with Workers...

coral basin
#

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'],
  },

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

sleek juniper
coral basin
#

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 🤔

sleek juniper
#

Should we open a issue on Stripe github to track down all these bugs?

bright vine
#

@coral basin thank you

coral basin
#

I am pretty sure this is not Stripe related but more some remix - cloudflare internals. My sophisticated guess would be cloudflare or just wrangler