how to work with es modules in a browser?

Browsers do not have Node.js style module resolution. You have to specify the exact URL to the module.

import fruits from "./fruits.js";

And remove this:

<script type="module" src="./fruits.js"></script>

… it doesn’t do anything. It’s only useful when you import it somewhere else.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top