Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Commit 9a343ce

Browse files
committed
fixup: s/type/entry-type doc
1 parent ea6a0d7 commit 9a343ce

File tree

3 files changed

+38
-36
lines changed

3 files changed

+38
-36
lines changed

doc/api/cli.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,19 @@ conjunction with native stack and other runtime environment data.
131131
added: v6.0.0
132132
-->
133133

134+
### `--entry-type=type`
135+
<!-- YAML
136+
added: REPLACEME
137+
-->
138+
139+
Used with `--experimental-modules`, this configures Node.js to interpret the
140+
initial entry point as CommonJS or as an ES module.
141+
142+
Valid values are `"commonjs"` and `"module"`. The default is to infer from
143+
the file extension and the `"type"` field in the nearest parent `package.json`.
144+
145+
Works for executing a file as well as `--eval`, `--print`, `STDIN`.
146+
134147
Enable FIPS-compliant crypto at startup. (Requires Node.js to be built with
135148
`./configure --openssl-fips`.)
136149

@@ -554,17 +567,6 @@ added: v2.4.0
554567

555568
Track heap object allocations for heap snapshots.
556569

557-
### `--type=type`
558-
559-
Used with `--experimental-modules`, this configures Node.js to interpret the
560-
initial entry point as CommonJS or as an ES module.
561-
562-
Valid values are `"commonjs"` and `"module"`. The default is to infer from
563-
the file extension and the `"type"` field in the nearest parent `package.json`.
564-
565-
Works for executing a file as well as `--eval`, `--print`, `STDIN`.
566-
567-
568570
### `--use-bundled-ca`, `--use-openssl-ca`
569571
<!-- YAML
570572
added: v6.11.0

doc/api/errors.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,26 +2223,14 @@ while trying to read and parse it.
22232223

22242224
> Stability: 1 - Experimental
22252225
2226-
The `--type=...` flag is not compatible with the Node.js REPL.
2227-
2228-
<a id="ERR_TYPE_MISMATCH"></a>
2229-
#### ERR_TYPE_MISMATCH
2230-
2231-
> Stability: 1 - Experimental
2232-
2233-
The `--type=commonjs` flag was used to attempt to execute an `.mjs` file or
2234-
a `.js` file where the nearest parent `package.json` contains
2235-
`"type": "module"`; or
2236-
the `--type=module` flag was used to attempt to execute a `.cjs` file or
2237-
a `.js` file where the nearest parent `package.json` either lacks a `"type"`
2238-
field or contains `"type": "commonjs"`.
2226+
The `--entry-type=...` flag is not compatible with the Node.js REPL.
22392227

22402228
<a id="ERR_INVALID_TYPE_FLAG"></a>
22412229
#### ERR_INVALID_TYPE_FLAG
22422230

22432231
> Stability: 1 - Experimental
22442232
2245-
An invalid `--type=...` flag value was provided.
2233+
An invalid `--entry-type=...` flag value was provided.
22462234

22472235
<a id="ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK"></a>
22482236
#### ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
@@ -2274,6 +2262,18 @@ size.
22742262
This `Error` is thrown when a read is attempted on a TTY `WriteStream`,
22752263
such as `process.stdout.on('data')`.
22762264

2265+
<a id="ERR_TYPE_MISMATCH"></a>
2266+
#### ERR_TYPE_MISMATCH
2267+
2268+
> Stability: 1 - Experimental
2269+
2270+
The `--entry-type=commonjs` flag was used to attempt to execute an `.mjs` file
2271+
or a `.js` file where the nearest parent `package.json` contains
2272+
`"type": "module"`; or
2273+
the `--entry-type=module` flag was used to attempt to execute a `.cjs` file or
2274+
a `.js` file where the nearest parent `package.json` either lacks a `"type"`
2275+
field or contains `"type": "commonjs"`.
2276+
22772277
[`'uncaughtException'`]: process.html#process_event_uncaughtexception
22782278
[`--force-fips`]: cli.html#cli_force_fips
22792279
[`Class: assert.AssertionError`]: assert.html#assert_class_assert_assertionerror

doc/api/esm.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,29 @@ loaded as an ES module.
4343
node --experimental-modules my-app.mjs
4444
```
4545

46-
### <code>--type=module</code> flag
46+
### <code>--entry-type=module</code> flag
4747

4848
Files ending with `.js` or `.mjs`, or lacking any extension,
49-
will be loaded as ES modules when the `--type=module` flag is set.
49+
will be loaded as ES modules when the `--entry-type=module` flag is set.
5050

5151
```sh
52-
node --experimental-modules --type=module my-app.js
52+
node --experimental-modules --entry-type=module my-app.js
5353
```
5454

55-
For completeness there is also `--type=commonjs`, for explicitly running a `.js`
56-
file as CommonJS. This is the default behavior if `--type` is
55+
For completeness there is also `--entry-type=commonjs`, for explicitly running
56+
a `.js` file as CommonJS. This is the default behavior if `--entry-type` is
5757
unspecified.
5858

59-
The `--type=module` flag can also be used to configure Node.js to treat
59+
The `--entry-type=module` flag can also be used to configure Node.js to treat
6060
as an ES module input sent in via `--eval` or `--print` (or `-e` or `-p`) or
6161
piped to Node.js via `STDIN`.
6262

6363
```sh
64-
node --experimental-modules --type=module --eval \
64+
node --experimental-modules --entry-type=module --eval \
6565
"import { sep } from 'path'; console.log(sep);"
6666

6767
echo "import { sep } from 'path'; console.log(sep);" | \
68-
node --experimental-modules --type=module
68+
node --experimental-modules --entry-type=module
6969
```
7070

7171
### <code>package.json</code> <code>"type"</code> field
@@ -420,8 +420,8 @@ to work.
420420
421421
<!-- eslint-skip -->
422422
```bash
423-
node --experimental-modules --type=module index.js # fails
424-
node --experimental-modules --type=module --experimental-json-modules index.js # works
423+
node --experimental-modules --entry-type=module index.js # fails
424+
node --experimental-modules --entry-type=module --experimental-json-modules index.js # works
425425
```
426426
427427
## Experimental Loader hooks
@@ -576,7 +576,7 @@ of these top-level routines.
576576
577577
_isMain_ is **true** when resolving the Node.js application entry point.
578578
579-
When using the `--type` flag, it overrides the ESM_FORMAT result while
579+
When using the `--entry-type` flag, it overrides the ESM_FORMAT result while
580580
providing errors in the case of explicit conflicts.
581581
582582
<details>

0 commit comments

Comments
 (0)