dawsbot / essential-eth

🪶 An alternative to ethers & web3 that's 10x smaller
https://eeth.dev
MIT License
304 stars 34 forks source link

Trouble Importing Modules #260

Closed wadader closed 5 months ago

wadader commented 1 year ago

I'm having trouble importing JsonRpcProvider in my node backend. Probably a module/common-js mix-up but hoping for some direction.


Importing like so import { JsonRpcProvider } from "essential-eth";

SyntaxError: Named export 'JsonRpcProvider' not found. The requested module 'essential-eth' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'essential-eth'; const { JsonRpcProvider } = pkg;

However, the second form of import, for instance by doing this : import EssentialEth from "essential-eth"; const provider = new EssentialEth.JsonRpcProvider(ENV.Blockchain.RPC_URL);

Causes:

import { BaseContract, Contract } from "./classes/Contract"; ^^^^^^ SyntaxError: Cannot use import statement outside a module

I am using "type": "module", not commonjs. In tsconfig.json, module is set to "module": "NodeNext"

dawsbot commented 5 months ago

Hey @wadader I'm slow to respond to this, but the latest anything v0.9.0 or newer should be fixed now!

Apologies for the slow support for this 🙏