'Why does using import break a module?
Why am I getting an error saying my function is undefined when I import a module?
I have a simple JavaScript module and whenever I import ethers, my functions display as no longer defined.
Before importing ethers
<button type="button" onclick="run();">Run my stuff</button>
<script type="module">
function run() {
console.log("Hello world!")
}
window.run = run;
</script>
After importing ethers
<button type="button" onclick="run();">Run my stuff</button>
<script type="module">
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.2.esm.min.js";
function run() {
console.log("Hello world!")
}
window.run = run;
</script>
Why is this happening?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
