Ethers.js: Why isn’t the module exported as default?

Created on 16 Oct 2018  Â·  6Comments  Â·  Source: ethers-io/ethers.js

Hello,

Basically I use import ether from "ethers" I get Undefined in general.

Any changes that could have broken the pipe ?

In adance thanks

discussion documentation

Most helpful comment

This has been updated in the documentation: https://docs.ethers.io/ethers.js/html/getting-started.html

Thanks! :)

All 6 comments

Heya! I forgot to add it to the migration documentation. Wallet.prototype.send was removed because it was fairly simple, added confusion and complicated the Signer API, while adding very little value.

Change wallet.send(address, amount) to wallet.sendTransaction({ to: address, value: amount}) and everything should be peachy. That was literally all that send did.

I’ll be sure to update the migration guide soon. Thanks! :)

Oh sorry. I think I totally misread this. Are you using TypeScript?

Try: import { ethers } from “ethers”;

Try: import { ethers } from “ethers”;

Hi @ricmoo, I'm using JS and I confirm the import statement you propose works. With that said, I wonder why isn't ethers the default export as it was in v3.0. I thought that was intuitive.

The problem is with how TypeScript/JavaScript ES6 imports work vs require.

They do not co-operate. :)

If I export the default, first of all TypeScript types complain because they aren’t actual JavaScript “things”. Secondly, anyone using require, needs to use var ethers = require(“ethers”).default.

You can still use const ethers = require(“ethers”) and that will work.

It’s annoying, and I’m open to better solutions, but this was the best I could find that worked for all the environments I want to support.

In the future, once ES3 support is dropped, this will be easier. :)

I confirm you can still use const ethers = require(“ethers”) and that will work. works.

Thanks the syntax import { ethers } works. This can be a nice update for documentation as well :)

This has been updated in the documentation: https://docs.ethers.io/ethers.js/html/getting-started.html

Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tomix3D picture Tomix3D  Â·  39Comments

fmsouza picture fmsouza  Â·  51Comments

subramanianv picture subramanianv  Â·  34Comments

Levino picture Levino  Â·  35Comments

fmsouza picture fmsouza  Â·  44Comments