node.js - bundle.js :50930 Uncaught TypeError: require(. ..).createServer 不是函数

标签 node.js stripe-payments browserify

我在我的网站上集成了 stripe api。我使用 stripe、express 和 http-browserify 创建了 bundle.js。并遇到此错误:

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

当我点击错误时,它给出错误:

Stripe.DEFAULT_TIMEOUT = require('http').createServer().timeout;

最佳答案

您使用了服务器端 stripe包,其中 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.

您不能在浏览器中使用它们。

客户端库 stripe.js 无法从 NPM 获得,因此您需要以老式的方式将其添加到客户端代码中,方法是:

<script src='https://js.stripe.com/v2/'></script>

关于node.js - bundle.js :50930 Uncaught TypeError: require(. ..).createServer 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40784697/

相关文章:

node.js - 使用 AWS 上的无服务器框架发送响应 header

javascript - 如何在没有浏览器或任何 HTML 的情况下在 Node.js 中使用 WebRTC API?

javascript - 我怎样才能在node js服务器中包含css js

stripe-payments - 如何创建订阅(使用 on_behalf_of 参数)与连接帐户的目的地转移?

JavaScript ES2015 动态继承与 browserify 和 babelify

node.js - 通过 Node.js 服务器流式传输 Youtube 视频

c# - Stripe webhook 签名失败 - Stripe.net

php - 自定义 Stripe 按钮不会触发 POST 方法

javascript - TSify 在 Browserify 期间忽略转换

javascript - 尝试请求浏览器版本的 NeDB 时出错