Skip to content

Commit c16dd4e

Browse files
authored
docs: Document that overrides only work in the root package.json (#7367)
<!-- What / Why --> <!-- Describe the request in detail. What it does and why it's being changed. --> Add documentation explaining that the `package.json` `"overrides"` field only takes effect at the root `package.json` of a project. Most of this text is copied from [the RFC](https://github.com/npm/rfcs/blob/main/accepted/0036-overrides.md#only-root-package-may-contain-overrides) which originally described this feature. ## References Fixes #4517.
1 parent ca15992 commit c16dd4e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/lib/content/configuring-npm/package-json.md

+7
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,13 @@ Overrides provide a way to replace a package in your dependency tree with
928928
another version, or another package entirely. These changes can be scoped as
929929
specific or as vague as desired.
930930

931+
Overrides are only considered in the root `package.json` file for a project.
932+
Overrides in installed dependencies (including
933+
[workspaces](/using-npm/workspaces)) are not considered in dependency tree
934+
resolution. Published packages may dictate their resolutions by pinning
935+
dependencies or using an
936+
[`npm-shrinkwrap.json`](/configuring-npm/npm-shrinkwrap-json) file.
937+
931938
To make sure the package `foo` is always installed as version `1.0.0` no matter
932939
what version your dependencies rely on:
933940

0 commit comments

Comments
 (0)