From 5c8c225991a03f11c4b81d170ffed0ec69304b44 Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Wed, 10 Sep 2025 16:35:43 +0200 Subject: [PATCH 1/2] src: change default config to package.json --- doc/api/cli.md | 2 +- doc/node.1 | 2 +- src/node_config_file.cc | 2 +- .../rc/default/{node.config.json => package.json} | 0 .../flag-propagation/{node.config.json => package.json} | 0 test/parallel/test-config-file.js | 8 ++++---- test/parallel/test-runner-flag-propagation.js | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) rename test/fixtures/rc/default/{node.config.json => package.json} (100%) rename test/fixtures/test-runner/flag-propagation/{node.config.json => package.json} (100%) diff --git a/doc/api/cli.md b/doc/api/cli.md index 6e0b337a2a39..ac5b1107ac9f 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1040,7 +1040,7 @@ added: > Stability: 1.0 - Early development If the `--experimental-default-config-file` flag is present, Node.js will look for a -`node.config.json` file in the current working directory and load it as a +`package.json` file in the current working directory and load it as a as configuration file. ### `--experimental-eventsource` diff --git a/doc/node.1 b/doc/node.1 index 691a5c914859..62086b36f23d 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -173,7 +173,7 @@ Enable experimental addon module support. Specifies the configuration file to load. . .It Fl -experimental-default-config-file -Enable support for automatically loading node.config.json. +Enable support for automatically loading configuration from package.json. . .It Fl -experimental-import-meta-resolve Enable experimental ES modules support for import.meta.resolve(). diff --git a/src/node_config_file.cc b/src/node_config_file.cc index e6c049b4d14f..980338745164 100644 --- a/src/node_config_file.cc +++ b/src/node_config_file.cc @@ -31,7 +31,7 @@ std::optional ConfigReader::GetDataFromArgs( } if (has_default_config_file) { - return "node.config.json"; + return "package.json"; } return std::nullopt; diff --git a/test/fixtures/rc/default/node.config.json b/test/fixtures/rc/default/package.json similarity index 100% rename from test/fixtures/rc/default/node.config.json rename to test/fixtures/rc/default/package.json diff --git a/test/fixtures/test-runner/flag-propagation/node.config.json b/test/fixtures/test-runner/flag-propagation/package.json similarity index 100% rename from test/fixtures/test-runner/flag-propagation/node.config.json rename to test/fixtures/test-runner/flag-propagation/package.json diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index cc235bfadae1..a411b31f242a 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -350,7 +350,7 @@ test('broken value in node_options', async () => { strictEqual(result.code, 9); }); -test('should use node.config.json as default', async () => { +test('should use package.json as default', async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--experimental-default-config-file', @@ -363,7 +363,7 @@ test('should use node.config.json as default', async () => { strictEqual(result.code, 0); }); -test('should override node.config.json when specificied', async () => { +test('should override package.json when specificied', async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings', '--experimental-default-config-file', @@ -383,7 +383,7 @@ test('should throw an error when the file is non readable', { skip: isWindows || process.getuid() === 0, }, async () => { tmpdir.refresh(); - const dest = join(tmpdir.path, 'node.config.json'); + const dest = join(tmpdir.path, 'package.json'); writeFileSync(dest, JSON.stringify({ nodeOptions: { 'max-http-header-size': 10 } })); @@ -395,7 +395,7 @@ test('should throw an error when the file is non readable', { ], { cwd: tmpdir.path, }); - match(result.stderr, /Cannot read configuration from node\.config\.json: permission denied/); + match(result.stderr, /Cannot read configuration from package\.json: permission denied/); strictEqual(result.stdout, ''); strictEqual(result.code, 9); }); diff --git a/test/parallel/test-runner-flag-propagation.js b/test/parallel/test-runner-flag-propagation.js index d5190251ef8d..d89d896bd4e1 100644 --- a/test/parallel/test-runner-flag-propagation.js +++ b/test/parallel/test-runner-flag-propagation.js @@ -15,7 +15,7 @@ const runner = path.join(fixtureDir, 'runner.mjs'); describe('test runner flag propagation', () => { describe('via command line', () => { const flagPropagationTests = [ - ['--experimental-config-file', 'node.config.json', ''], + ['--experimental-config-file', 'package.json', ''], ['--experimental-default-config-file', '', false], ['--env-file', '.env', '.env'], ['--env-file-if-exists', '.env', '.env'], From 22e4ea23ae81117438ff248cf7d7b9c818321b53 Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Wed, 10 Sep 2025 17:41:29 +0200 Subject: [PATCH 2/2] lib: set config schema additionalProperties to true --- doc/node-config-schema.json | 2 +- lib/internal/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/node-config-schema.json b/doc/node-config-schema.json index bffae1fc6179..64a4e387642b 100644 --- a/doc/node-config-schema.json +++ b/doc/node-config-schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": false, + "additionalProperties": true, "properties": { "$schema": { "type": "string" diff --git a/lib/internal/options.js b/lib/internal/options.js index be1dc6a842c5..9b363a34eb77 100644 --- a/lib/internal/options.js +++ b/lib/internal/options.js @@ -65,7 +65,7 @@ function generateConfigJsonSchema() { const schema = { __proto__: null, $schema: 'https://json-schema.org/draft/2020-12/schema', - additionalProperties: false, + additionalProperties: true, properties: { $schema: { __proto__: null,