@@ -61,12 +61,12 @@ Node.js will treat the following as [ES modules][] when passed to `node` as the
6161initial input, or when referenced by ` import ` statements or ` import() `
6262expressions:
6363
64- - Files with an ` .mjs ` extension.
64+ * Files with an ` .mjs ` extension.
6565
66- - Files with a ` .js ` extension when the nearest parent ` package.json ` file
66+ * Files with a ` .js ` extension when the nearest parent ` package.json ` file
6767 contains a top-level [ ` "type" ` ] [ ] field with a value of ` "module" ` .
6868
69- - Strings passed in as an argument to ` --eval ` , or piped to ` node ` via ` STDIN ` ,
69+ * Strings passed in as an argument to ` --eval ` , or piped to ` node ` via ` STDIN ` ,
7070 with the flag ` --input-type=module ` .
7171
7272* Code containing syntax only successfully parsed as [ ES modules] [ ] , such as
@@ -82,28 +82,28 @@ Node.js will treat the following as [CommonJS][] when passed to `node` as the
8282initial input, or when referenced by ` import ` statements or ` import() `
8383expressions:
8484
85- - Files with a ` .cjs ` extension.
85+ * Files with a ` .cjs ` extension.
8686
87- - Files with a ` .js ` extension when the nearest parent ` package.json ` file
87+ * Files with a ` .js ` extension when the nearest parent ` package.json ` file
8888 contains a top-level field [ ` "type" ` ] [ ] with a value of ` "commonjs" ` .
8989
90- - Strings passed in as an argument to ` --eval ` or ` --print ` , or piped to ` node `
90+ * Strings passed in as an argument to ` --eval ` or ` --print ` , or piped to ` node `
9191 via ` STDIN ` , with the flag ` --input-type=commonjs ` .
9292
9393Aside from these explicit cases, there are other cases where Node.js defaults to
9494one module system or the other based on the value of the
9595[ ` --experimental-default-type ` ] [ ] flag:
9696
97- - Files ending in ` .js ` or with no extension, if there is no ` package.json ` file
97+ * Files ending in ` .js ` or with no extension, if there is no ` package.json ` file
9898 present in the same folder or any parent folder.
9999
100- - Files ending in ` .js ` or with no extension, if the nearest parent
100+ * Files ending in ` .js ` or with no extension, if the nearest parent
101101 ` package.json ` field lacks a ` "type" ` field; unless the folder is inside a
102102 ` node_modules ` folder. (Package scopes under ` node_modules ` are always treated
103103 as CommonJS when the ` package.json ` file lacks a ` "type" ` field, regardless
104104 of ` --experimental-default-type ` , for backward compatibility.)
105105
106- - Strings passed in as an argument to ` --eval ` or piped to ` node ` via ` STDIN ` ,
106+ * Strings passed in as an argument to ` --eval ` or piped to ` node ` via ` STDIN ` ,
107107 when ` --input-type ` is unspecified.
108108
109109This flag currently defaults to ` "commonjs" ` , but it may change in the future to
@@ -159,37 +159,37 @@ Node.js has two systems for resolving a specifier and loading modules.
159159
160160There is the CommonJS module loader:
161161
162- - It is fully synchronous.
163- - It is responsible for handling ` require() ` calls.
164- - It is monkey patchable.
165- - It supports [ folders as modules] [ ] .
166- - When resolving a specifier, if no exact match is found, it will try to add
162+ * It is fully synchronous.
163+ * It is responsible for handling ` require() ` calls.
164+ * It is monkey patchable.
165+ * It supports [ folders as modules] [ ] .
166+ * When resolving a specifier, if no exact match is found, it will try to add
167167 extensions (` .js ` , ` .json ` , and finally ` .node ` ) and then attempt to resolve
168168 [ folders as modules] [ ] .
169- - It treats ` .json ` as JSON text files.
170- - ` .node ` files are interpreted as compiled addon modules loaded with
169+ * It treats ` .json ` as JSON text files.
170+ * ` .node ` files are interpreted as compiled addon modules loaded with
171171 ` process.dlopen() ` .
172- - It treats all files that lack ` .json ` or ` .node ` extensions as JavaScript
172+ * It treats all files that lack ` .json ` or ` .node ` extensions as JavaScript
173173 text files.
174- - It can only be used to [ load ECMASCript modules from CommonJS modules] [ ] if
174+ * It can only be used to [ load ECMASCript modules from CommonJS modules] [ ] if
175175 the module graph is synchronous (that contains no top-level ` await ` ) when
176176 ` --experimental-require-module ` is enabled.
177177 When used to load a JavaScript text file that is not an ECMAScript module,
178178 the file will be loaded as a CommonJS module.
179179
180180There is the ECMAScript module loader:
181181
182- - It is asynchronous, unless it's being used to load modules for ` require() ` .
183- - It is responsible for handling ` import ` statements and ` import() ` expressions.
184- - It is not monkey patchable, can be customized using [ loader hooks] [ ] .
185- - It does not support folders as modules, directory indexes (e.g.
182+ * It is asynchronous, unless it's being used to load modules for ` require() ` .
183+ * It is responsible for handling ` import ` statements and ` import() ` expressions.
184+ * It is not monkey patchable, can be customized using [ loader hooks] [ ] .
185+ * It does not support folders as modules, directory indexes (e.g.
186186 ` './startup/index.js' ` ) must be fully specified.
187- - It does no extension searching. A file extension must be provided
187+ * It does no extension searching. A file extension must be provided
188188 when the specifier is a relative or absolute file URL.
189- - It can load JSON modules, but an import type attribute is required.
190- - It accepts only ` .js ` , ` .mjs ` , and ` .cjs ` extensions for JavaScript text
189+ * It can load JSON modules, but an import type attribute is required.
190+ * It accepts only ` .js ` , ` .mjs ` , and ` .cjs ` extensions for JavaScript text
191191 files.
192- - It can be used to load JavaScript CommonJS modules. Such modules
192+ * It can be used to load JavaScript CommonJS modules. Such modules
193193 are passed through the ` cjs-module-lexer ` to try to identify named exports,
194194 which are available if they can be determined through static analysis.
195195 Imported CommonJS modules have their URLs converted to absolute
@@ -241,12 +241,12 @@ import 'commonjs-package/src/index.mjs';
241241The ` .mjs ` and ` .cjs ` extensions can be used to mix types within the same
242242package:
243243
244- - Within a ` "type": "module" ` package, Node.js can be instructed to
244+ * Within a ` "type": "module" ` package, Node.js can be instructed to
245245 interpret a particular file as [ CommonJS] [ ] by naming it with a ` .cjs `
246246 extension (since both ` .js ` and ` .mjs ` files are treated as ES modules within
247247 a ` "module" ` package).
248248
249- - Within a ` "type": "commonjs" ` package, Node.js can be instructed to
249+ * Within a ` "type": "commonjs" ` package, Node.js can be instructed to
250250 interpret a particular file as an [ ES module] [ ] by naming it with an ` .mjs `
251251 extension (since both ` .js ` and ` .cjs ` files are treated as CommonJS within a
252252 ` "commonjs" ` package).
@@ -647,25 +647,25 @@ For example, a package that wants to provide different ES module exports for
647647Node.js implements the following conditions, listed in order from most
648648specific to least specific as conditions should be defined:
649649
650- - ` "node-addons" ` - similar to ` "node" ` and matches for any Node.js environment.
650+ * ` "node-addons" ` - similar to ` "node" ` and matches for any Node.js environment.
651651 This condition can be used to provide an entry point which uses native C++
652652 addons as opposed to an entry point which is more universal and doesn't rely
653653 on native addons. This condition can be disabled via the
654654 [ ` --no-addons ` flag] [ ] .
655- - ` "node" ` - matches for any Node.js environment. Can be a CommonJS or ES
655+ * ` "node" ` - matches for any Node.js environment. Can be a CommonJS or ES
656656 module file. _ In most cases explicitly calling out the Node.js platform is
657657 not necessary._
658- - ` "import" ` - matches when the package is loaded via ` import ` or
658+ * ` "import" ` - matches when the package is loaded via ` import ` or
659659 ` import() ` , or via any top-level import or resolve operation by the
660660 ECMAScript module loader. Applies regardless of the module format of the
661661 target file. _ Always mutually exclusive with ` "require" ` ._
662- - ` "require" ` - matches when the package is loaded via ` require() ` . The
662+ * ` "require" ` - matches when the package is loaded via ` require() ` . The
663663 referenced file should be loadable with ` require() ` although the condition
664664 matches regardless of the module format of the target file. Expected
665665 formats include CommonJS, JSON, native addons, and ES modules
666666 if ` --experimental-require-module ` is enabled. _ Always mutually
667667 exclusive with ` "import" ` ._
668- - ` "default" ` - the generic fallback that always matches. Can be a CommonJS
668+ * ` "default" ` - the generic fallback that always matches. Can be a CommonJS
669669 or ES module file. _ This condition should always come last._
670670
671671Within the [ ` "exports" ` ] [ ] object, key order is significant. During condition
@@ -766,14 +766,14 @@ Since custom package conditions require clear definitions to ensure correct
766766usage, a list of common known package conditions and their strict definitions
767767is provided below to assist with ecosystem coordination.
768768
769- - ` "types" ` - can be used by typing systems to resolve the typing file for
769+ * ` "types" ` - can be used by typing systems to resolve the typing file for
770770 the given export. _ This condition should always be included first._
771- - ` "browser" ` - any web browser environment.
772- - ` "development" ` - can be used to define a development-only environment
771+ * ` "browser" ` - any web browser environment.
772+ * ` "development" ` - can be used to define a development-only environment
773773 entry point, for example to provide additional debugging context such as
774774 better error messages when running in a development mode. _ Must always be
775775 mutually exclusive with ` "production" ` ._
776- - ` "production" ` - can be used to define a production environment entry
776+ * ` "production" ` - can be used to define a production environment entry
777777 point. _ Must always be mutually exclusive with ` "development" ` ._
778778
779779For other runtimes, platform-specific condition key definitions are maintained
@@ -783,16 +783,16 @@ New conditions definitions may be added to this list by creating a pull request
783783to the [ Node.js documentation for this section] [ ] . The requirements for listing
784784a new condition definition here are that:
785785
786- - The definition should be clear and unambiguous for all implementers.
787- - The use case for why the condition is needed should be clearly justified.
788- - There should exist sufficient existing implementation usage.
789- - The condition name should not conflict with another condition definition or
786+ * The definition should be clear and unambiguous for all implementers.
787+ * The use case for why the condition is needed should be clearly justified.
788+ * There should exist sufficient existing implementation usage.
789+ * The condition name should not conflict with another condition definition or
790790 condition in wide usage.
791- - The listing of the condition definition should provide a coordination
791+ * The listing of the condition definition should provide a coordination
792792 benefit to the ecosystem that wouldn't otherwise be possible. For example,
793793 this would not necessarily be the case for company-specific or
794794 application-specific conditions.
795- - The condition should be such that a Node.js user would expect it to be in
795+ * The condition should be such that a Node.js user would expect it to be in
796796 Node.js core documentation. The ` "types" ` condition is a good example: It
797797 doesn't really belong in the [ Runtime Keys] [ ] proposal but is a good fit
798798 here in the Node.js docs.
@@ -1044,17 +1044,17 @@ additional fields which are ignored by Node.js and not documented here.
10441044
10451045The following fields in ` package.json ` files are used in Node.js:
10461046
1047- - [ ` "name" ` ] [ ] - Relevant when using named imports within a package. Also used
1047+ * [ ` "name" ` ] [ ] - Relevant when using named imports within a package. Also used
10481048 by package managers as the name of the package.
1049- - [ ` "main" ` ] [ ] - The default module when loading the package, if exports is not
1049+ * [ ` "main" ` ] [ ] - The default module when loading the package, if exports is not
10501050 specified, and in versions of Node.js prior to the introduction of exports.
1051- - [ ` "packageManager" ` ] [ ] - The package manager recommended when contributing to
1051+ * [ ` "packageManager" ` ] [ ] - The package manager recommended when contributing to
10521052 the package. Leveraged by the [ Corepack] [ ] shims.
1053- - [ ` "type" ` ] [ ] - The package type determining whether to load ` .js ` files as
1053+ * [ ` "type" ` ] [ ] - The package type determining whether to load ` .js ` files as
10541054 CommonJS or ES modules.
1055- - [ ` "exports" ` ] [ ] - Package exports and conditional exports. When present,
1055+ * [ ` "exports" ` ] [ ] - Package exports and conditional exports. When present,
10561056 limits which submodules can be loaded from within the package.
1057- - [ ` "imports" ` ] [ ] - Package imports, for use by modules within the package
1057+ * [ ` "imports" ` ] [ ] - Package imports, for use by modules within the package
10581058 itself.
10591059
10601060### ` "name" `
@@ -1071,7 +1071,7 @@ changes:
10711071 description: Remove the `--experimental-resolve-self` option.
10721072-->
10731073
1074- - Type: {string}
1074+ * Type: {string}
10751075
10761076``` json
10771077{
@@ -1092,7 +1092,7 @@ The `"name"` field can be used in addition to the [`"exports"`][] field to
10921092added: v0.4.0
10931093-->
10941094
1095- - Type: {string}
1095+ * Type: {string}
10961096
10971097``` json
10981098{
@@ -1124,7 +1124,7 @@ added:
11241124
11251125> Stability: 1 - Experimental
11261126
1127- - Type: {string}
1127+ * Type: {string}
11281128
11291129``` json
11301130{
@@ -1153,7 +1153,7 @@ changes:
11531153 description: Unflag `--experimental-modules`.
11541154-->
11551155
1156- - Type: {string}
1156+ * Type: {string}
11571157
11581158The ` "type" ` field defines the module format that Node.js uses for all
11591159` .js ` files that have that ` package.json ` file as their nearest parent.
@@ -1164,7 +1164,7 @@ Files ending with `.js` are loaded as ES modules when the nearest parent
11641164
11651165The nearest parent ` package.json ` is defined as the first ` package.json ` found
11661166when searching in the current folder, that folder's parent, and so on up
1167- until a node_modules folder or the volume root is reached.
1167+ until a node \_ modules folder or the volume root is reached.
11681168
11691169``` json
11701170// package.json
@@ -1226,7 +1226,7 @@ changes:
12261226 description: Implement conditional exports.
12271227-->
12281228
1229- - Type: {Object} | {string} | {string\[ ] }
1229+ * Type: {Object} | {string} | {string\[ ] }
12301230
12311231``` json
12321232{
@@ -1255,7 +1255,7 @@ added:
12551255 - v12.19.0
12561256-->
12571257
1258- - Type: {Object}
1258+ * Type: {Object}
12591259
12601260``` json
12611261// package.json
0 commit comments