Skip to content

Commit 0c6040b

Browse files
marco-ippolitoaduh95
authored andcommitted
src: support multiple versions in node.config.json
Signed-off-by: Marco Ippolito <marcoippolito54@gmail.com> PR-URL: #66830 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 73b6f41 commit 0c6040b

6 files changed

Lines changed: 1593 additions & 1035 deletions

File tree

‎doc/api/cli.md‎

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

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

1044+
The configuration file can target a specific Node.js major version with
1045+
`nodeVersion`:
1046+
1047+
```json
1048+
{
1049+
"nodeVersion": 25,
1050+
"nodeOptions": {
1051+
"watch-path": "src"
1052+
}
1053+
}
1054+
```
1055+
1056+
To keep multiple version-specific configurations in the same file, use the
1057+
`configs` array. Node.js will use the first entry whose `nodeVersion` matches
1058+
the current Node.js major version:
1059+
1060+
```json
1061+
{
1062+
"$schema": "https://nodejs.org/dist/latest-v26.x/docs/node-config-schema.json",
1063+
"configs": [
1064+
{
1065+
"nodeVersion": 25,
1066+
"config": {
1067+
"$schema": "https://nodejs.org/dist/latest-v25.x/docs/node-config-schema.json",
1068+
"nodeOptions": {
1069+
"watch-path": "src"
1070+
}
1071+
}
1072+
}
1073+
]
1074+
}
1075+
```
1076+
1077+
When `configs` is used, the top level may only contain `$schema` and
1078+
`configs`. Each `configs` item must define an integer `nodeVersion` and an
1079+
object `config`. A single top-level config does not require `nodeVersion`, but
1080+
if present it must match the current Node.js major version.
1081+
10441082
When a namespace is present in the
10451083
configuration file, Node.js automatically enables the corresponding flag
10461084
(e.g., `--test`, `--watch`, `--permission`). This allows you to configure

0 commit comments

Comments
 (0)