tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
388 stars 259 forks source link

TypeError: TronWeb is not a constructor #524

Closed masumetc closed 3 weeks ago

masumetc commented 1 month ago

i am getting this issue

TypeError: TronWeb is not a constructor at Object. (D:\nodeprojects\index.js:3:17) at Module._compile (node:internal/modules/cjs/loader:1368:14) at Module._extensions..js (node:internal/modules/cjs/loader:1426:10) at Module.load (node:internal/modules/cjs/loader:1205:32) at Module._load (node:internal/modules/cjs/loader:1021:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) at node:internal/main/run_main_module:28:49

in my index.js file looks like this

const TronWeb = require('tronweb');

const tronWeb = new TronWeb({
  fullHost: 'https://api.trongrid.io',
  headers: { 'TRON-PRO-API-KEY': 'your api key' },
  privateKey: 'your private key'
});
start940315 commented 1 month ago

It seems like you are using tronweb@6, please use const { TronWeb } = require('tronweb'). To know more, read migration guide.