Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bundle.js:50930 Uncaught TypeError: require(...).createServer is not a function

I have integrated stripe api in my website. I have created bundle.js using stripe, express and http-browserify. and encountered this error:

bundle.js:50930 Uncaught TypeError: require(...).createServer is not a function at Object.

at Object.require.stripe.../package.json

at s bundle.js:1:262 at /post.html:11:14(anonymous function)

@ bundle.js:50930require.stripe.../package.json

@ bundle.js:51112s

@ bundle.js:1(anonymous function) @ post.html:11

When I click on error it give error on :

Stripe.DEFAULT_TIMEOUT = require('http').createServer().timeout;
like image 965
Zeeshan Shafiq Avatar asked May 12 '26 22:05

Zeeshan Shafiq


1 Answers

You used the server-side stripe package, of which the documentation states:

These are serverside bindings only

If you're looking to install stripe.js, our clientside tokenization library - this is not it. These are serverside node.js bindings only.

You can't use these in a browser.

The client-side library, stripe.js, isn't available from NPM so you need to add it to your client-side code the old-fashioned way, by using:

<script src='https://js.stripe.com/v2/'></script>
like image 188
robertklep Avatar answered May 15 '26 15:05

robertklep