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

Commit fd5b55a

Browse files
committed
fixup: s/type/entry-type doc
1 parent 69840ed commit fd5b55a

File tree

3 files changed

+37
-42
lines changed

3 files changed

+37
-42
lines changed

doc/api/cli.md

+13-11
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

@@ -556,17 +569,6 @@ added: v2.4.0
556569

557570
Track heap object allocations for heap snapshots.
558571

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

doc/api/errors.md

+13-20
Original file line numberDiff line numberDiff line change
@@ -2223,26 +2223,7 @@ 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"`.
2239-
2240-
<a id="ERR_INVALID_TYPE_FLAG"></a>
2241-
#### ERR_INVALID_TYPE_FLAG
2242-
2243-
> Stability: 1 - Experimental
2244-
2245-
An invalid `--type=...` flag value was provided.
2226+
The `--entry-type=...` flag is not compatible with the Node.js REPL.
22462227

22472228
<a id="ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK"></a>
22482229
#### ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
@@ -2274,6 +2255,18 @@ size.
22742255
This `Error` is thrown when a read is attempted on a TTY `WriteStream`,
22752256
such as `process.stdout.on('data')`.
22762257

2258+
<a id="ERR_TYPE_MISMATCH"></a>
2259+
#### ERR_TYPE_MISMATCH
2260+
2261+
> Stability: 1 - Experimental
2262+
2263+
The `--entry-type=commonjs` flag was used to attempt to execute an `.mjs` file
2264+
or a `.js` file where the nearest parent `package.json` contains
2265+
`"type": "module"`; or
2266+
the `--entry-type=module` flag was used to attempt to execute a `.cjs` file or
2267+
a `.js` file where the nearest parent `package.json` either lacks a `"type"`
2268+
field or contains `"type": "commonjs"`.
2269+
22772270
[`'uncaughtException'`]: process.html#process_event_uncaughtexception
22782271
[`--force-fips`]: cli.html#cli_force_fips
22792272
[`Class: assert.AssertionError`]: assert.html#assert_class_assert_assertionerror

doc/api/esm.md

+11-11
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
@@ -419,8 +419,8 @@ The `--experimental-json-modules` flag is needed for the module
419419
to work.
420420
421421
```bash
422-
node --experimental-modules --type=module index.js # fails
423-
node --experimental-modules --type=module --experimental-json-modules index.js # works
422+
node --experimental-modules --entry-type=module index.js # fails
423+
node --experimental-modules --entry-type=module --experimental-json-modules index.js # works
424424
```
425425
426426
## Experimental Loader hooks
@@ -575,7 +575,7 @@ of these top-level routines.
575575
576576
_isMain_ is **true** when resolving the Node.js application entry point.
577577
578-
When using the `--type` flag, it overrides the ESM_FORMAT result while
578+
When using the `--entry-type` flag, it overrides the ESM_FORMAT result while
579579
providing errors in the case of explicit conflicts.
580580
581581
<details>

0 commit comments

Comments
 (0)