-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERR_UNSUPPORTED_DIR_IMPORT in web3-eth-abi/lib/esm/coders/encode.js with node >18 #6535
Comments
sorry, apparently this error happens on versions below 18, checking which one works now |
same error here, any workaround guys? *I downgraded to 1.9.0 to solve the problem for now, had the error even installing the 4.0.3 |
I think the problem is that the code is written using the CommonJS style of importing an “index.js” file (which it’s calling a “directory import”): import { encodeTuple } from './base'; However, Node.js is not resolving import specifiers like that any more (at least not without optional flags): https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions
The workaround for Node 18 users is to start your program with a flag:
I think the fix for the library is to import the module using the full file path instead: import { encodeTuple } from './base/index.js'; |
This problem is not happening because of you. I was getting same error and I delete ^ on package version. from "web3": "^4.1.1-dev.86f0cdb.0", So, You can use previous versions. I am sure somebody will fix it later. |
Thanks for pointing out this issue, @jacksonrayhamilton if you would like to contribute and add this edit in a PR that would be great. otherwise one of our devs will help get on this. |
try this: https://github.com/web3/web3.js/blob/4.x/packages/web3-eth-abi/src/coders/base/array.ts ->line 21 -> https://github.com/web3/web3.js/blob/4.x/packages/web3-eth-abi/src/coders/base/tuple.ts ->line 22 -> https://github.com/web3/web3.js/blob/4.x/packages/web3-eth-abi/src/coders/encode.ts -> line 20 -> ***Caution about the extentions (.ts and .js). I have tried this on the .js version of web3 4.2.0 |
PR has been merged for this, you can use this for now until we release a patch. thank you everyone web3@4.2.1-dev.a0d6730.0 |
Expected behavior
web3-eth-abi/lib/esm/coders/encode.js should be able to import from web3-eth-abi/lib/esm/coders/base
Actual behavior
web3-eth-abi/lib/esm/coders/encode.js errors with ERR_UNSUPPORTED_DIR_IMPORT in nodejs versions above or equal to 18
Steps to reproduce the behavior
Logs
Node.js v18.18.2
10.69 error Command failed with exit code 1.
10.69 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Environment
Node: v18.18.2
Yarn: 1.22.19
web3-eth-abi: 4.1.2
OS: ubuntu 22.04
The text was updated successfully, but these errors were encountered: