简体   繁体   中英

Meteor “cannot find module 'braintree'”

I'm trying to integrate Braintree payments with my site, but Meteor keeps giving the following error:

Error: Cannot find module 'Braintree'

I added meteor to my project using both meteor add ulexus:braintree and meteor add hiukim:braintree-helper .

I followed along with this to try and get my project working. Here's my code:

// 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);

I have also tried installing Braintree with sudo npm install braintree but that didn't work either. If I try without Braintree = ... I get the error cannot call method baseUrl on undefined .

I would really appreciate any help. Note: I have never used Braintree before and have only recently started using Meteor.

Thanks!

Just add braintree with

npm install braintree

and use it with

var braintree = require("braintree");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM