Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion doc/node-config-schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"$schema": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function generateConfigJsonSchema() {
const schema = {
__proto__: null,
$schema: 'https://json-schema.org/draft/2020-12/schema',
additionalProperties: false,
additionalProperties: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this is changing to be more permissive?

Is that because the entire package.json is validated instead of a specific property?

Copy link
Member Author

@marco-ippolito marco-ippolito Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this requires more investigation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m wondering if a new configuration-specific property is needed at the root level to encapsulate what is now in node.config.json at the root level.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also a very very good idea - instead of adding N keys to package.json, this should only be adding 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

properties: {
Copy link
Member

@styfle styfle Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see nodeOptions here but are we missing testRunner?

Note testRunner is documented here: https://nodejs.org/api/cli.html#--experimental-config-fileconfig

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testRunner is a "namespace" and it's being added dynamically from line 96.
Only nodeOption is hardcoded atm

$schema: {
__proto__: null,
Expand Down
2 changes: 1 addition & 1 deletion src/node_config_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ std::optional<std::string_view> ConfigReader::GetDataFromArgs(
}

if (has_default_config_file) {
return "node.config.json";
return "package.json";
}

return std::nullopt;
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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 }
}));
Expand All @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-runner-flag-propagation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Loading