ES Modules Logo ESModules.com

Master JavaScript ES Modules

One module system for browsers, Node.js, Deno, and Bun. Learn import and export in ten minutes, then come back for the exact answer when a build, an import, or a migration breaks.

A night city of modules where app.js imports math.js, utils.js and api.js along beams of light
A program is a graph of files. app.js imports what it needs and nothing leaks into the global scope.

ES Modules in 30 Seconds

One file exports values. Another file imports them by name. That is the whole idea - everything else on this site is detail.

math.js - share it

export const add = (a, b) => a + b;

export default function square(n) {
  return n * n;
}

app.js - use it

import square, { add } from './math.js';

console.log(add(2, 3));  // 5
console.log(square(4));  // 16

Run it in a browser

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

Run it in Node.js

{ "type": "module" }

The browser line goes in your HTML. The Node.js line goes in package.json, then node app.js runs it. Next: every import and export form, or browser and Node.js setup in full.

Start With What Everyone Else Reads

The eight guides readers open most. Pick the question you are trying to answer today.

How an ES Module Loads

Three phases, always in this order. Knowing them explains most of the errors you will ever see.

Diagram titled How an ES Module Loads with three phases in order: Construction - fetch and parse every file; Instantiation - link exports to imports; Evaluation - run each module once. The whole graph is linked before any code runs.
Imports are resolved before your first line runs, which is why a typo in a path fails the whole graph.

1. Construction

The host starts at your entry file, finds every import, and fetches and parses each file it points to. Nothing runs yet. A wrong path, a missing extension, or a blocked request fails here.

2. Instantiation

Every export gets a slot in memory and every import is wired to the slot it names. These are live bindings, not copies. Asking for a name the module does not export fails here, before any code executes.

3. Evaluation

Module code runs once, dependencies first. Import the same file from ten places and it still executes a single time, so module-level state is shared by every importer.

Go deeper: how a specifier becomes a file, and live bindings, cycles, and top-level await.

Here Because Something Broke?

The six messages that send most people looking. Each one links to its cause and the exact fix.

See the full error reference

What You'll Learn

Every page on the site, grouped into five tracks. Start with Core if you are new, jump to Practices when something is broken, or use Reference to look up a specific answer.

A glowing learning trail climbing a mountain of code blocks from fundamentals to tooling

Core

The syntax, the mental model, and how ES Modules relate to what came before.

Resolution & Configuration

How a specifier becomes a file, and how to configure the tools that decide.

Ecosystem

Where ES Modules actually run, and what each platform supports today.

Practices

Getting it right, making it fast, and fixing it when it breaks.

Reference

Look something up, copy something out, or check a definition.

Learn by Doing

Don't just read about ES Modules - run real code in your browser.

Each example is a real set of module files loaded by your browser's own module loader, with the console output captured next to the code. Change an import, break an export on purpose, and watch which of the three loading phases reports it.

A live code editor running an ES module, with Hello, ESM! appearing in the console

12 Live Examples

Run real ES Module code directly in your browser. See console output, test different imports, and learn interactively.

  • Basic Import/Export
  • Named vs Default Exports
  • Default Exports
  • Dynamic Imports
  • Top-Level Await
  • import.meta

Edit in CodePen

Every example includes a one-click export to CodePen. Experiment freely, modify code, and see results instantly.

  • One-click CodePen export
  • Fully editable code
  • Live console output
  • Share your experiments
  • Fork and customize

Real Execution

No simulations! Actual ES Modules running in isolated iframes with real browser behavior and console output.

  • Native ES Module execution
  • Real-time console capture
  • Isolated environment
  • Multiple file support
  • Instant feedback
A curly-brace lighthouse guiding module boats across a sea of code to a bright harbor

Our Mission: Empowering Developers with the Future of JavaScript Modules

JavaScript has evolved. The days of global namespace pollution, complex bundler configurations, and competing module formats are giving way to a standardized, powerful, and native solution: ES Modules. This is the future of writing clean, reusable, and performant code for the web, and ESModules.com is your definitive resource for mastering it.

Our mission is to accelerate the awareness and adoption of this critical technology. We believe that a deep understanding of ES Modules is no longer optional - it's a foundational skill for modern developers committed to continuous learning and building for the long term.

Created By Developers, For Developers

This site isn't just a collection of documentation; it's a living project built from real-world experience. The team at RJL.dev - a group of practicing software engineers and architects - created and actively maintains every piece of content you'll find here. We've navigated the challenges, debugged the tricky edge cases, and optimized the patterns so you can learn from our expertise.

Because we are in the trenches coding every day, we stand behind our content with confidence. We are committed to providing you with:

ESModules.com is more than a website; it's our commitment to elevating the JavaScript community. We invite you to dive in, explore the resources, and join us in building the future of the web - one module at a time.

Frequently Asked Questions

Quick answers to the ES Modules questions we hear most. Need more? The full FAQ answers 33 of them, grouped by error message, browser, Node.js, TypeScript, tooling, and migration.

Floating code-bracket question marks unfolding into answer cards with checkmarks

Get in Touch

Found a mistake, a stale version number, or a question this site does not answer? Tell us.