Closed sinawic closed 5 months ago
TronWeb v5.x is recommended to be used with bundlers such as webpack and vite. If you want to use directly, you can install the beta version:
npm install tronweb@beta
hey, thanks for the reply
now the problem seems to have been solved but i get the following error:
index.js:22
const wallet = tronweb.createRandom()
^
TypeError: tronweb.createRandom is not a function
at init (index.js:22:26)
at Timeout._onTimeout (index.js:42:3)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
Node.js v20.12.0
I had same problem...
Temporary solution is :
Yes, it looks ugly.
I get the error exactly the time when i require/import
tronweb
the workaround I'm now able to run my project is to install version 4 of tronweb.
"tronweb": "^4.4.0"
to be exact
Temporary solution is :
- using Beta version
- create an instance like following const tronWebInst = new TronWeb.TronWeb({ 'fullHost': 'https://api.trongrid.io', 'headers': { "TRON-PRO-API-KEY": APIKey }, });
Yes, it looks ugly.
You can use named imports like below:
import { TronWeb, utils as TronWebUtils, Trx, TransactionBuilder, Contract, Event, Plugin } from 'tronweb';
Temporary solution is :
- using Beta version
- create an instance like following const tronWebInst = new TronWeb.TronWeb({ 'fullHost': 'https://api.trongrid.io', 'headers': { "TRON-PRO-API-KEY": APIKey }, });
Yes, it looks ugly.
You can use named imports like below:
import { TronWeb, utils as TronWebUtils, Trx, TransactionBuilder, Contract, Event, Plugin } from 'tronweb';
Ok , I see. you should update readme.md as:
ES Modules (ESM) import * CommonJS require()
personally , i never like ES6 ..since it's good to read the code ,but very very suck on debug.. Young developers don't care about the debug & error handler.. because their code "never had error", if program had "unexpected results", it must be the fault of customer.
ES Modules (ESM) import * CommonJS require()
@raymondmeg
problem is require(***)
does not work in latest version (5.x
)
ES Modules (ESM) import * CommonJS require()
@raymondmeg
problem is
require(***)
does not work in latest version (5.x
)
Have you solved your problem? If not, please provide a demo to reproduce it so I can tell the problem.
I get the error exactly the time when i
require/import
tronweb the workaround I'm now able to run my project is to install version 4 of tronweb."tronweb": "^4.4.0"
to be exact
turns out I'm not using any of the features of 5.x
whenever I change the version to 5.x
in my package.json file I get the error.
no matther I change my project type to module
or not (using require/import)
I still get the error
Error [ERR_REQUIRE_ESM]: require() of ES Module secp256k1/index.js from TronWeb.node.js
@start940315
I just figure out how this happened. You must have install the latest version of @noble/secp256k1
. But you should install the @noble/secp256k1@1.7.1
. So please try follow:
npm install @noble/secp256k1@1.7.1
my problem is solved
npm install @noble/secp256k1@1.7.1
this was the key!
man thanks!
hey, I'm getting this really bothering error I can't find a way to bypass when I simply install
tronweb
and importing it in my projectnode -v
v20.12.0
npm -v10.5.0
uname -aLinux sinawic 5.11.0-34-generic #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
full error:
I don't know if I'm doing anything wrong or is there anything that is really not right!