mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
doc: fix extension in esm example
PR-URL: https://github.com/nodejs/node/pull/33408 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
1 parent
24faa37a09
commit
7f9ccd6d89
1 file changed
+4
-4
+4
-4
@@ -16,7 +16,7 @@ code for reuse. Modules are defined using a variety of [`import`][] and
|
||||
The following example of an ES module exports a function:
|
||||
|
||||
```js
|
||||
// addTwo.js
|
||||
// addTwo.mjs
|
||||
function addTwo(num) {
|
||||
return num + 2;
|
||||
}
|
||||
@@ -24,11 +24,11 @@ function addTwo(num) {
|
||||
export { addTwo };
|
||||
```
|
||||
|
||||
The following example of an ES module imports the function from `addTwo.js`:
|
||||
The following example of an ES module imports the function from `addTwo.mjs`:
|
||||
|
||||
```js
|
||||
// app.js
|
||||
import { addTwo } from './addTwo.js';
|
||||
// app.mjs
|
||||
import { addTwo } from './addTwo.mjs';
|
||||
|
||||
// Prints: 6
|
||||
console.log(addTwo(4));
|
||||
|
||||
Reference in new issue
Block a user