Comments (8)
Just a quick note: Erdjs is intended for use in the browser, so it's mostly a webpack/configuration issue.
Will try later to reproduce the problem :)
from mx-sdk-js-core.
Ok I have reproduced the error and it seems like __dirname is used in the following files:
https://github.com/ElrondNetwork/elrond-sdk-erdjs/blob/main/src/testutils/wallets.ts#L49
According to nodejs.org its a difference between es modules and commonjs modules.
https://nodejs.org/api/esm.html#esm_differences_between_es_modules_and_commonjs
One can also take a look at the issue here:
nodejs/help#2907
So as far as I understood it we should replace all occurences of __dirname with smth like this:
nodejs/help#2907 (comment)
from mx-sdk-js-core.
Have you done any other changes? I tried this fix and I get
/node_modules/@elrondnetwork/erdjs/out/smartcontracts/wrapper/systemWrapper.js:4:18-31 - Error: export 'fileURLToPath' (imported as 'fileURLToPath') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)
./node_modules/@elrondnetwork/erdjs/out/testutils/wallets.js:4:19-32 - Error: export 'fileURLToPath' (imported as 'fileURLToPath') was not found in 'url' (possible exports: Url, format, parse, resolve, resolveObject)
The thing is....
the exported method si right there, I don't understand how it was not found. Tried to rebuild and all and still getting this.
Did it just "work" for you out of the box after making the changes?
from mx-sdk-js-core.
Fixed it by doing this:
import { URL } from 'url';
const __dirname = new URL('.', import.meta.url).pathname;
but instead now I'm getting
Uncaught ReferenceError: exports is not defined
only in the wallet.js file we had to change the __dirname earlier.
Probably it's the same issue where this is not available in an ES module.
from mx-sdk-js-core.
Thanks @MWFIAE for the later fix.
And in node_modules in @elrondnetwork/erdjs/out/smartcontracts/wrapper/systemWrapper.js
SystemConstants.SYSTEM_ABI_PATH = path_1.default.join(__dirname, "../../../abi");
replaced with
SystemConstants.SYSTEM_ABI_PATH = path_1.default.join(".", "../../../abi");
from mx-sdk-js-core.
Hi, i have setup a git repository with a workaround for using erdjs with angular. https://github.com/andreigiura/angular-erdjs-project , it is not pretty, since i have compiled the browser version of erdjs and paste it in the project, but it work for now, until we will figure it out.
from mx-sdk-js-core.
Hi, i have setup a git repository with a workaround for using erdjs with angular. https://github.com/andreigiura/angular-erdjs-project , it is not pretty, since i have compiled the browser version of erdjs and paste it in the project, but it work for now, until we will figure it out.
Have you guys made any progress on figuring this out?
from mx-sdk-js-core.
This has been fixed in erdjs 10 (we are currently preparing the release), since the packages causing the issue have been extracted to separate repositories:
- https://github.com/ElrondNetwork/elrond-sdk-erdjs-walletcore
- https://github.com/ElrondNetwork/elrond-sdk-erdjs-contract-wrappers
As of v10, erdjs does not depend on fs
and crypto
anymore.
from mx-sdk-js-core.
Related Issues (20)
- Proposal: re-consider required arguments for Transaction constructor HOT 1
- Adjust / improve ResultsParser to properly handle outcome of relayed transactions HOT 2
- Upgrade breaks Interaction serialization with native variadic arguments HOT 3
- Have "enum.valueOf()" return "fields" as an object (not as an array)
- Add support for `counted-variadic` type in ABI parsing HOT 1
- Setup eslint on sdk-js-* HOT 2
- Setup release.yml on sdk-js-* and sdk-py-* HOT 1
- By default, use TRANSACTION_VERSION_DEFAULT = 2 HOT 1
- On SmartContract.computeAddress(), do extra validation
- Rewrite "TypeExpressionParser" HOT 3
- When building a "relayedV2" transaction, make sure to inherit the version from the inner transaction (both JS and PY) HOT 2
- Use BigInt instead of BigNumber HOT 1
- SignableMessage: one does not simply decode a payload that was previously created using "toJSON()" HOT 1
- Send NFT Functionality Not Working in MultiversX SDK-Core HOT 2
- Migration support: "v12" to "v13" (April 2024) HOT 14
- TokenOperationsOutcomeParser: error when a transaction has multiple events HOT 3
- [v13] Problem with `checkArgumentsCardinality` HOT 9
- Missing `upgradeConstructor` in AbiRegistry HOT 3
- Problem with smart contracts ESDTTransfer in sdk-core 13.0.0-beta.9 and newer HOT 7
- When generating *.d.ts files, skip (ignore) private members
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mx-sdk-js-core.