ethers.js
ethers.js copied to clipboard
need to use .cjs/.mjs file extensions
Ethers Version
6.15.0
Search Terms
No response
Describe the Problem
https://github.com/ethers-io/ethers.js/blob/9fd9d41d017a5e3b329aca47c79786e69cd40b99/package.json#L38-L39
Running Node.js v20.18.0, when you import a file that ends in .js, and the nearest package.json doesn't say type: "module" (and the package.json in ethers doesn't), it gets parsed as CommonJS.
So it just chokes with a SyntaxError when it sees ESM syntax.
Either ESM files have to end in .mjs, or "type" has to be added to package.json and all CommonJS files have to end in .cjs.
Code Snippet
`import ethers from 'ethers'`
Contract ABI
Errors
Environment
No response
Environment (Other)
No response