【问题标题】:Meteor "cannot find module 'braintree'"流星“找不到模块‘braintree’”
【发布时间】:2015-03-10 22:55:03
【问题描述】:

我正在尝试将 Braintree 付款与我的网站集成,但 Meteor 不断给出以下错误:

Error: Cannot find module 'Braintree'

我使用 meteor add ulexus:braintreemeteor add hiukim:braintree-helper 将流星添加到我的项目中。

我跟随this 尝试让我的项目正常运行。这是我的代码:

// inside Meteor.startup
Braintree = Npm.require('braintree');
var config = Braintree.connect({
  environment: Braintree.Environment.Sandbox,
  merchantId: "my merchant id",
  privateKey: "my private key",
  publicKey: "my public key"
});
BraintreeHelper.getInstance().connect(config);

我也尝试使用sudo npm install braintree 安装 Braintree,但这也不起作用。如果我尝试不使用Braintree = ...,则会收到错误cannot call method baseUrl on undefined

我非常感谢任何帮助。注意:我以前从未使用过 Braintree,最近才开始使用 Meteor。

谢谢!

【问题讨论】:

  • 我也无法让它工作。不过我知道至少有一位 Braintree 开发人员使用 Meteor atm,所以希望他们能提供帮助。
  • 好吧,我终于让它工作了。删除 Braintree = Npm.require('braintree')BraintreeHelper.getInstance().connect(config) 行(考虑到 Atmospherejs 自述文件据说有这些行有点奇怪),然后更新 packages.json 文件以包含 "hokum:braintree-helper" : "1.0.0"
  • @Trent 我在 Braintree 工作。如果这解决了您的问题,请将其作为答案发布,以便我可以投票给它,其他人可以更轻松地找到它。很高兴你能弄明白!
  • 这里有同样的错误。工作得很好。然后我更新到 Meteor 1.0.4 现在出现上述错误。

标签: javascript node.js meteor braintree


【解决方案1】:

只需添加braintree与

npm install braintree

并与它一起使用

var braintree = require("braintree");

【讨论】:

    【解决方案2】:

    我在 react 项目中遇到了同样的问题,

    npm install braintree 不工作。

    如果它在您的情况下也不起作用,请全局安装。

    npm install -g braintree
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-05
      • 2017-05-30
      • 2017-03-31
      • 1970-01-01
      • 2016-10-20
      • 2018-03-26
      • 2016-12-23
      • 1970-01-01
      相关资源
      最近更新 更多