Podum
August 7, 2017, 7:56pm
1
After importing a node module i get
TypeError: Class extends value [object Object] is not a constructor or null
the code that sits in the module is…
'use strict';
let version = require('../package.json').version;
let Config = require('./braintree/config').Config;
let Environment = require('./braintree/environment').Environment;
let BraintreeGateway = require('./braintree/braintree_gateway').BraintreeGateway;
let errorTypes = require('./braintree/error_types').errorTypes;
let Transaction = require('./braintree/transaction').Transaction;
let CreditCard = require('./braintree/credit_card').CreditCard;
let PayPalAccount = require('./braintree/paypal_account').PayPalAccount;
let AndroidPayCard = require('./braintree/android_pay_card').AndroidPayCard;
let ApplePayCard = require('./braintree/apple_pay_card').ApplePayCard;
let VenmoAccount = require('./braintree/venmo_account').VenmoAccount;
let CoinbaseAccount = require('./braintree/coinbase_account').CoinbaseAccount;
let AmexExpressCheckoutCard = require('./braintree/amex_express_checkout_card').AmexExpressCheckoutCard;
let VisaCheckoutCard = require('./braintree/visa_checkout_card').VisaCheckoutCard;
let MasterpassCard = require('./braintree/masterpass_card').MasterpassCard;
let CreditCardVerification = require('./braintree/credit_card_verification').CreditCardVerification;
let Subscription = require('./braintree/subscription').Subscription;
let MerchantAccount = require('./braintree/merchant_account').MerchantAccount;
let PaymentInstrumentTypes = require('./braintree/payment_instrument_types').PaymentInstrumentTypes;
let WebhookNotification = require('./braintree/webhook_notification').WebhookNotification;
let TestingGateway = require('./braintree/testing_gateway').TestingGateway;
let ValidationErrorCodes = require('./braintree/validation_error_codes').ValidationErrorCodes;
let CreditCardDefaults = require('./braintree/test/credit_card_defaults').CreditCardDefaults;
let CreditCardNumbers = require('./braintree/test/credit_card_numbers').CreditCardNumbers;
let MerchantAccountTest = require('./braintree/test/merchant_account').MerchantAccountTest;
let Nonces = require('./braintree/test/nonces').Nonces;
let TransactionAmounts = require('./braintree/test/transaction_amounts').TransactionAmounts;
let connect = config => new BraintreeGateway(new Config(config)); // eslint-disable-line func-style
let Test = {
CreditCardDefaults: CreditCardDefaults,
CreditCardNumbers: CreditCardNumbers,
MerchantAccountTest: MerchantAccountTest,
Nonces: Nonces,
TransactionAmounts: TransactionAmounts
};
module.exports = {
connect: connect,
version: version,
Environment: Environment,
errorTypes: errorTypes,
Transaction: Transaction,
CreditCard: CreditCard,
PayPalAccount: PayPalAccount,
AndroidPayCard: AndroidPayCard,
ApplePayCard: ApplePayCard,
VenmoAccount: VenmoAccount,
CoinbaseAccount: CoinbaseAccount,
AmexExpressCheckoutCard: AmexExpressCheckoutCard,
VisaCheckoutCard: VisaCheckoutCard,
MasterpassCard: MasterpassCard,
CreditCardVerification: CreditCardVerification,
Subscription: Subscription,
MerchantAccount: MerchantAccount,
PaymentInstrumentTypes: PaymentInstrumentTypes,
WebhookNotification: WebhookNotification,
TestingGateway: TestingGateway,
ValidationErrorCodes: ValidationErrorCodes,
Test: Test
};
Please edit your post, it is not very readable at the moment.
Use the </>
button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ```
manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.
Does the error message point you to a specific line?
What leads you to believe that this code is compatible with Ionic or Angular?
Podum
August 7, 2017, 10:38pm
4
I used another node module from the same author and it worked fine.
But I see that this one wont be so simple by the look of the code.
I’m wondering if anyone knows a solution for this.
I would very much like to keep using ionic.
Podum
August 7, 2017, 10:42pm
5
Does anyone know what the error message means?
I think i can work a solution if i knew what it meant.
Definitely a strange one. I would google and read all the SO responses.
This here could be relevant:
opened 11:27AM - 22 Feb 17 UTC
closed 01:39PM - 22 Feb 17 UTC
invalid
module
<!--
Thank you for reporting an issue.
This issue tracker is for bugs and is… sues found within Node.js core.
If you require more general support please file an issue on our help
repo. https://github.com/nodejs/help
Please fill in as much of the template below as you're able.
Version: output of `node -v`
Platform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)
Subsystem: if known, please specify affected core module name
If possible, please provide code that demonstrates the problem, keeping it as
simple and free of external dependencies as you are able.
-->
* **Version**: 7.6.0
* **Platform**: Windows 10
* **Subsystem**: ?
Having two files:
```
// base.js
const Concrete = require('./Concrete');
class Base {
isConcrete(instance) {
return instance instanceof Concrete;
}
}
module.exports = Base;
```
```
// concrete.js
const Base = require('./Base');
class Concrete extends Base {
}
module.exports = Concrete;
```
I run the second file by `node concrete.js` and get:
```
TypeError: Class extends value #<Object> is not a constructor or null
```
while If I run the second by `node Concrete.js`, I get no error.
Are you on a system with case-sensitive file names?
Podum
August 9, 2017, 3:08pm
7
had trouble finding them. typed in ionic framework so responses. Couldn’t find anything.
What does SO stand for?
Podum:
What does SO stand for?
Sorry, SO = Stack Overflow.
Podum
August 21, 2017, 9:04pm
9
I searched. I currently have not found a solution for this particular error message.
I think it has something to do with trying to call the arrow function, “connect” (which is in the node package file i illustrated earlier) from within the ts file.
import * as braintree from 'braintree';
...
gateway: any;
...
this.gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: 'personalMerchantId',
publicKey: 'personalPublicKey',
privateKey: 'personalPrivateKey'
});
naree
August 31, 2017, 1:26pm
10
Did you ever find a solution to this?
Podum
September 1, 2017, 6:24pm
11
I have not found a solution yet. Thank you for showing interest on here and on Stack Overflow. Hopefully soon.
Also please join my chatroom on StackOverflow for all things Ionic related.
https://chat.stackoverflow.com/rooms/153499/ionic-3
Podum
March 17, 2018, 8:36am
12
I have spoken with many braintree employees (because many of them would just dance around the topic) and finally came to the understanding that the braintree node package was just not written for the ionic/angular framework.
the code provided by the braintree documentation is meant to sit on a server (the backend) which you must then access through an api that you develop on your client project (the frontend).
This is a much more secure way of connecting to braintree and how the braintree developers would prefer us to connect.