Skip to content
Open
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
17 changes: 7 additions & 10 deletions doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ Node.js has two module systems: CommonJS modules and [ECMAScript modules][].

By default, Node.js will treat the following as CommonJS modules:

* Files with a `.cjs` extension;
* Files with a `.cjs` extension.

* Files with a `.js` extension when the nearest parent `package.json` file
contains a top-level field [`"type"`][] with a value of `"commonjs"`.
* Files with a `.js` extension or without an extension, when the nearest parent
`package.json` file contains a top-level field [`"type"`][] with a value of
`"commonjs"`.

* Files with a `.js` extension or without an extension, when the nearest parent
`package.json` file doesn't contain a top-level field [`"type"`][] or there is
Expand All @@ -90,13 +91,9 @@ By default, Node.js will treat the following as CommonJS modules:
tools and loaders to determine how the files in the package should be
interpreted.

* Files with an extension that is not `.mjs`, `.cjs`, `.json`, `.node`, or `.js`
(when the nearest parent `package.json` file contains a top-level field
[`"type"`][] with a value of `"module"`, those files will be recognized as
CommonJS modules only if they are being included via `require()`, not when
used as the command-line entry point of the program).

See [Determining module system][] for more details.
Comment on lines -98 to -99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to delete this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. It’s a bullet point list. Should I move after the last bullet point?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was fine as is? There’s already a non-bulleted paragraph after this one, within this section.

* Files with an extension that is not `.mjs`, `.cjs`, `.json`, `.node`, or `.js`,
when the nearest parent `package.json` file contains a top-level field
[`"type"`][] with a value of `"module"`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should remain unless there’s a reason to remove it.

Suggested change
[`"type"`][] with a value of `"module"`.
[`"type"`][] with a value of `"module"`.
See [Determining module system][] for more details.


Calling `require()` always use the CommonJS module loader. Calling `import()`
always use the ECMAScript module loader.
Expand Down
Loading