Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ ECMAScript modules are [the official standard format][] to package JavaScript
code for reuse. Modules are defined using a variety of [`import`][] and
[`export`][] statements.

First, to enable modules in Node.js for `.js` extensions, ensure there is a
`package.json` file in the root of the project with `"type": "module"` set:

<!-- eslint-skip -->
```js
// package.json
{
"name": "app",
"type": "module"
}
```

> An alternative to setting `"type": "module" is to use the `.mjs` extension.

The following example of an ES module exports a function:

```js
Expand Down