stripe-node: fresh npm install stripe and error
Just importing stripe (import StripeFactory from 'stripe';) or using require shown in the README causes an error:
ERROR in ./~/stripe/lib/stripe.js
Module not found: Error: Cannot resolve module 'child_process' in /Users/rkoberg/Sites/fwi/node_modules/stripe/lib
@ ./~/stripe/lib/stripe.js 24:11-35
I am using the fix mentioned here: https://github.com/webpack/webpack.js.org/issues/107
But can a maintainer fix this. The fix for your module is also at the link above, specifically:
The proper course is the ask the module author to make the module browser compatible. The author can add browser: { fs: false, child_process: false } to the package.json to tell webpack that it’s ok for the module to get an empty object for these modules.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 24 (10 by maintainers)
Yes. The only supported method of including stripe.js is via https://js.stripe.com/v2/ (primarily for compliance reasons)
OK. I was confused about the difference between Stripe.js and node-stripe. I thought it was the same library, and that the docs at https://stripe.com/docs/stripe.js were more fully realized at https://stripe.com/docs/api/node; that only certain calls would require the private key and others only needed the public key. For example, I thought I would be able to GET products and skus/variants on the client (rather than needing to proxy through my app server), but I see/understand now I can’t. Apologies for my confusion. Fwiw, I think Stripe.js is a bad name for a browser/client library that can only parse a form to get a single use token. Stripe.js seems more like a name for a library/module that can do all things Stripe. Perhaps names like stripe-client.js and stripe-server.js would be more clear?