【问题标题】:Cannot resolve 'child_process' in Stripe, fixes lead to require being undefined无法解析 Stripe 中的“child_process”,修复导致需要未定义
【发布时间】:2019-07-09 13:00:09
【问题描述】:

我正在尝试在我的应用程序中使用 Stripe,当我这样做时,我在构建过程中收到此错误:

./node_modules/stripe/lib/utils.js 中的错误模块未找到:错误: 无法解析“PATH\node”中的“child_process” _modules\stripe\lib'

当我像这样将我的 webpack 开发配置更改为目标节点时:

export default {
  ...,
  target: 'node',
  ...
}

我收到一个错误,要求未定义,网上到处都表明这是由以下语句引起的,该语句不在我的 webpack 配置中:

externals: [nodeExternals()]

this 问题所示。

【问题讨论】:

    标签: webpack stripe-payments


    【解决方案1】:

    我猜你在前端应用程序中使用了来自npmstripe。但是这个包是一个服务器端包。您不能将它集成到您​​的客户端代码(如 React/Angular)中,您必须在服务器端使用它,例如 Node.js。

    您将在此处找到有关如何在客户端包含条带的详细说明:https://stripe.com/docs/stripe-js/reference#including-stripejs

    【讨论】:

    • 你能具体说明一下,你链接了一个非常长的文档链接
    猜你喜欢
    • 2020-07-24
    • 2018-11-18
    • 2019-04-24
    • 2021-05-17
    • 2017-04-24
    • 2021-12-25
    • 2018-05-03
    • 1970-01-01
    • 2019-06-22
    相关资源
    最近更新 更多