Skip to content

Commit a40a7dc

Browse files
src: support multiple versions in node.config.json
1 parent 8173251 commit a40a7dc

6 files changed

Lines changed: 1611 additions & 1040 deletions

File tree

doc/api/cli.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,44 @@ The configuration file supports namespace-specific options:
10911091

10921092
* Namespace fields like `test`, `watch`, and `permission` contain configuration specific to that subsystem.
10931093

1094+
The configuration file can target a specific Node.js major version with
1095+
`nodeVersion`:
1096+
1097+
```json
1098+
{
1099+
"nodeVersion": 25,
1100+
"nodeOptions": {
1101+
"watch-path": "src"
1102+
}
1103+
}
1104+
```
1105+
1106+
To keep multiple version-specific configurations in the same file, use the
1107+
`configs` array. Node.js will use the first entry whose `nodeVersion` matches
1108+
the current Node.js major version:
1109+
1110+
```json
1111+
{
1112+
"$schema": "https://nodejs.org/dist/latest-v26.x/docs/node-config-schema.json",
1113+
"configs": [
1114+
{
1115+
"nodeVersion": 25,
1116+
"config": {
1117+
"$schema": "https://nodejs.org/dist/latest-v25.x/docs/node-config-schema.json",
1118+
"nodeOptions": {
1119+
"watch-path": "src"
1120+
}
1121+
}
1122+
}
1123+
]
1124+
}
1125+
```
1126+
1127+
When `configs` is used, the top level may only contain `$schema` and
1128+
`configs`. Each `configs` item must define an integer `nodeVersion` and an
1129+
object `config`. A single top-level config does not require `nodeVersion`, but
1130+
if present it must match the current Node.js major version.
1131+
10941132
When a namespace is present in the
10951133
configuration file, Node.js automatically enables the corresponding flag
10961134
(e.g., `--test`, `--watch`, `--permission`). This allows you to configure

0 commit comments

Comments
 (0)