Javascript ES6 TypeError Class constructor Client cannot be invoked without new

0 votes

I have a class written in Javascript ES6. When I try to execute nodemon command I always see this error TypeError: Class constructor Client cannot be invoked without 'new'

The full error is mentioned below:

/Users/akshaysood/Blockchain/fabricSDK/dist/application/Transaction.js:45
        return (0, _possibleConstructorReturn3.default)(this, (FBClient.__proto__ || (0, _getPrototypeOf2.default)(FBClient)).call(this, props));
                                                                                                                              ^

TypeError: Class constructor Client cannot be invoked without 'new'
    at new FBClient (/Users/akshaysood/Blockchain/fabricSDK/dist/application/Transaction.js:45:127)
    at Object.<anonymous> (/Users/akshaysood/Blockchain/fabricSDK/dist/application/Transaction.js:195:14)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/akshaysood/Blockchain/fabricSDK/dist/routes/users.js:11:20)

What I am trying to do is, I have created a class and then created an instance of that class. Then I am trying to export that variable.

The class structure is defined below:

class FBClient extends FabricClient{

    constructor(props){
        super(props);
    }

<<< FUNCTIONS >>>

}

How I am trying to export the variable ->

var client = new FBClient();
client.loadFromConfig(config);

export default client = client;
May 5, 2020 in Blockchain by kartik
• 37,520 points
22,814 views

1 answer to this question.

0 votes

Hello @kartik,

In package.json you can use targets configuration with @babel/preset-env. set the esmodules as 'true'.

Below is the example how I am using in my file:

  "babel": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "targets": {
            "esmodules": true
          }
        }
      ],
      "@babel/preset-react",
      "@babel/preset-flow"
    ],
    "plugins": [
      "@babel/plugin-proposal-class-properties"
    ]
  },

Hope it works! and if you need to know more about javascript, then you should join one of our Java certification class without any delay.

Thank You!!

answered May 5, 2020 by Niroj
• 82,840 points

Related Questions In Blockchain

+1 vote
1 answer

Can a data be altered in a blockchain without changing its hash?

Yes, it should work. The authentication practice ...READ MORE

answered Apr 8, 2018 in Blockchain by Shashank
• 10,400 points
894 views
0 votes
1 answer

Solidity difference array with and without new keyword.

Creating arrays with variable length in memory ...READ MORE

answered Aug 16, 2018 in Blockchain by digger
• 26,740 points
1,646 views
+1 vote
1 answer

Unable to convert variable to GMP when initializing Bitpay client class (Laravel)

Bitpay automatically uses the encrypted file store, ...READ MORE

answered Sep 10, 2018 in Blockchain by slayer
• 29,370 points
1,091 views
0 votes
1 answer
0 votes
1 answer

Ethereum Node Connection: TypeError: Cannot read property 'version' of undefined

In the code that you are using ...READ MORE

answered Oct 24, 2018 in Blockchain by Omkar
• 69,220 points
1,932 views
+4 votes
2 answers

Hyperledger Fabric issue: orderer client failed to connect to orderer.xxx.net:7050: failed to create new connection

Hey @gujiwork, Try making the following changes: docker-compose-base.yaml and ...READ MORE

answered Nov 5, 2018 in Blockchain by Omkar
• 69,220 points
19,901 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,674 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,143 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP