Skip to content
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
632fb34
docs: clarify versioned override parent behavior
ded-furby Jun 10, 2026
324cf79
docs: fix scoped override spec references
ded-furby Jun 11, 2026
a2c003b
docs: clarify scoped override reference usage
ded-furby Jun 17, 2026
4dd7ef6
docs: clarify scoped override reference syntax
ded-furby Jun 17, 2026
2f5de91
docs: clarify scoped override reference forms
ded-furby Jun 17, 2026
6088f2b
docs: clarify scoped override reference examples
ded-furby Jun 18, 2026
d1146bd
docs: clarify scoped override references
ded-furby Jun 18, 2026
597aff5
docs: correct scoped override reference example
ded-furby Jun 18, 2026
2416b83
docs: clarify scoped override reference comments
ded-furby Jun 18, 2026
4dfff94
docs: clarify scoped override references
ded-furby Jun 18, 2026
b574dac
docs: correct scoped override reference example
ded-furby Jun 18, 2026
74c39e9
docs: trim scoped override examples
ded-furby Jun 18, 2026
15f02a8
docs: clarify scoped override reference example
ded-furby Jun 19, 2026
7fb88bc
docs: trim override scope reference note
ded-furby Jun 19, 2026
43d0856
docs: clarify scoped override difference in example
ded-furby Jun 19, 2026
ee9fd09
docs: trim scoped override example block
ded-furby Jun 19, 2026
afe09b5
docs: tighten scoped override example wording
ded-furby Jun 19, 2026
008a0a3
docs: tighten scoped override reference wording
ded-furby Jun 19, 2026
d49e687
docs: clarify scoped override contrast
ded-furby Jun 19, 2026
c5088fb
docs: trim scoped override wording
ded-furby Jun 19, 2026
65a5b62
docs: trim scoped override note wording
ded-furby Jun 19, 2026
c63c1f5
docs: simplify scoped override note
ded-furby Jun 19, 2026
a22e68c
docs: clarify scoped override example intent
ded-furby Jun 20, 2026
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
36 changes: 27 additions & 9 deletions docs/lib/content/configuring-npm/package-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -965,23 +965,41 @@ To override `@npm/foo` to `1.0.0`, but only when it's a child of `@npm/bar@2.0.0
}
```

Versioned override keys do not just limit when nested overrides apply.
They also replace the matched package with that version or range.
In this example, the parent key both matches and preserves `@npm/bar@2.0.0`
while applying the nested `@npm/foo` override.

If you want to keep the parent package on its existing spec while only
overriding its children, set `"."` explicitly:

```json
{
"dependencies": {
"@npm/bar": "^2.0.0"
},
"overrides": {
"@npm/bar@2.0.0": {
".": "$@npm/bar",
"@npm/foo": "1.0.0"
}
}
}
```

You may not set an override for a package that you directly depend on unless both the dependency and the override itself share the exact same spec.
To make this limitation easier to deal with, overrides may also be defined as a reference to a spec for a direct dependency by prefixing the name of the package you wish the version to match with a `$`.
You can resolve a child override against a direct dependency by using a `$` prefix with the full package name.
For scoped packages, keep the scope: use `$@scope/name`.
That allows, for example, `@npm/bar` to inherit the direct dependency spec from `@npm/foo` while still overriding `@npm/bar` at the same time:

```json
{
"dependencies": {
"@npm/foo": "^1.0.0"
},
"overrides": {
// BAD, will throw an EOVERRIDE error
// "foo": "^2.0.0"
// GOOD, specs match so override is allowed
// "foo": "^1.0.0"
// BEST, the override is defined as a reference to the dependency
"@npm/foo": "$foo",
// the referenced package does not need to match the overridden one
"@npm/bar": "$foo"
"@npm/foo": "$@npm/foo",
"@npm/bar": "$@npm/foo"
}
}
```
Expand Down
Loading