@@ -142,7 +142,7 @@ <h1 id="packagejson">package.json</h1>
142
142
143
143
< section id ="table_of_contents ">
144
144
< h2 id ="table-of-contents "> Table of contents</ h2 >
145
- < div id ="_table_of_contents "> < ul > < li > < a href ="#description "> Description</ a > </ li > < li > < a href ="#name "> name</ a > </ li > < li > < a href ="#version "> version</ a > </ li > < li > < a href ="#description2 "> description</ a > </ li > < li > < a href ="#keywords "> keywords</ a > </ li > < li > < a href ="#homepage "> homepage</ a > </ li > < li > < a href ="#bugs "> bugs</ a > </ li > < li > < a href ="#license "> license</ a > </ li > < li > < a href ="#people-fields-author-contributors "> people fields: author, contributors</ a > </ li > < li > < a href ="#funding "> funding</ a > </ li > < li > < a href ="#files "> files</ a > </ li > < li > < a href ="#main "> main</ a > </ li > < li > < a href ="#browser "> browser</ a > </ li > < li > < a href ="#bin "> bin</ a > </ li > < li > < a href ="#man "> man</ a > </ li > < li > < a href ="#directories "> directories</ a > </ li > < ul > < li > < a href ="#directoriesbin "> directories.bin</ a > </ li > < li > < a href ="#directoriesman "> directories.man</ a > </ li > </ ul > < li > < a href ="#repository "> repository</ a > </ li > < li > < a href ="#scripts "> scripts</ a > </ li > < li > < a href ="#config "> config</ a > </ li > < li > < a href ="#dependencies "> dependencies</ a > </ li > < ul > < li > < a href ="#urls-as-dependencies "> URLs as Dependencies</ a > </ li > < li > < a href ="#git-urls-as-dependencies "> Git URLs as Dependencies</ a > </ li > < li > < a href ="#github-urls "> GitHub URLs</ a > </ li > < li > < a href ="#local-paths "> Local Paths</ a > </ li > </ ul > < li > < a href ="#devdependencies "> devDependencies</ a > </ li > < li > < a href ="#peerdependencies "> peerDependencies</ a > </ li > < li > < a href ="#peerdependenciesmeta "> peerDependenciesMeta</ a > </ li > < li > < a href ="#bundleddependencies "> bundledDependencies</ a > </ li > < li > < a href ="#optionaldependencies "> optionalDependencies</ a > </ li > < li > < a href ="#engines "> engines</ a > </ li > < li > < a href ="#os "> os</ a > </ li > < li > < a href ="#cpu "> cpu</ a > </ li > < li > < a href ="#private "> private</ a > </ li > < li > < a href ="#publishconfig "> publishConfig</ a > </ li > < li > < a href ="#workspaces "> workspaces</ a > </ li > < li > < a href ="#default-values "> DEFAULT VALUES</ a > </ li > < li > < a href ="#see-also "> SEE ALSO</ a > </ li > </ ul > </ div >
145
+ < div id ="_table_of_contents "> < ul > < li > < a href ="#description "> Description</ a > </ li > < li > < a href ="#name "> name</ a > </ li > < li > < a href ="#version "> version</ a > </ li > < li > < a href ="#description2 "> description</ a > </ li > < li > < a href ="#keywords "> keywords</ a > </ li > < li > < a href ="#homepage "> homepage</ a > </ li > < li > < a href ="#bugs "> bugs</ a > </ li > < li > < a href ="#license "> license</ a > </ li > < li > < a href ="#people-fields-author-contributors "> people fields: author, contributors</ a > </ li > < li > < a href ="#funding "> funding</ a > </ li > < li > < a href ="#files "> files</ a > </ li > < li > < a href ="#main "> main</ a > </ li > < li > < a href ="#browser "> browser</ a > </ li > < li > < a href ="#bin "> bin</ a > </ li > < li > < a href ="#man "> man</ a > </ li > < li > < a href ="#directories "> directories</ a > </ li > < ul > < li > < a href ="#directoriesbin "> directories.bin</ a > </ li > < li > < a href ="#directoriesman "> directories.man</ a > </ li > </ ul > < li > < a href ="#repository "> repository</ a > </ li > < li > < a href ="#scripts "> scripts</ a > </ li > < li > < a href ="#config "> config</ a > </ li > < li > < a href ="#dependencies "> dependencies</ a > </ li > < ul > < li > < a href ="#urls-as-dependencies "> URLs as Dependencies</ a > </ li > < li > < a href ="#git-urls-as-dependencies "> Git URLs as Dependencies</ a > </ li > < li > < a href ="#github-urls "> GitHub URLs</ a > </ li > < li > < a href ="#local-paths "> Local Paths</ a > </ li > </ ul > < li > < a href ="#devdependencies "> devDependencies</ a > </ li > < li > < a href ="#peerdependencies "> peerDependencies</ a > </ li > < li > < a href ="#peerdependenciesmeta "> peerDependenciesMeta</ a > </ li > < li > < a href ="#bundleddependencies "> bundledDependencies</ a > </ li > < li > < a href ="#optionaldependencies "> optionalDependencies</ a > </ li > < li > < a href ="#overrides "> overrides</ a > </ li > < li > < a href ="#engines "> engines</ a > </ li > < li > < a href ="#os "> os</ a > </ li > < li > < a href ="#cpu "> cpu</ a > </ li > < li > < a href ="#private "> private</ a > </ li > < li > < a href ="#publishconfig "> publishConfig</ a > </ li > < li > < a href ="#workspaces "> workspaces</ a > </ li > < li > < a href ="#default-values "> DEFAULT VALUES</ a > </ li > < li > < a href ="#see-also "> SEE ALSO</ a > </ li > </ ul > </ div >
146
146
</ section >
147
147
148
148
< div id ="_content "> < h3 id ="description "> Description</ h3 >
@@ -800,6 +800,88 @@ <h3 id="optionaldependencies">optionalDependencies</h3>
800
800
</ code > </ pre >
801
801
< p > Entries in < code > optionalDependencies</ code > will override entries of the same name in
802
802
< code > dependencies</ code > , so it's usually best to only put in one place.</ p >
803
+ < h3 id ="overrides "> overrides</ h3 >
804
+ < p > If you need to make specific changes to dependencies of your dependencies, for
805
+ example replacing the version of a dependency with a known security issue,
806
+ replacing an existing dependency with a fork, or making sure that the same
807
+ version of a package is used everywhere, then you may add an override.</ p >
808
+ < p > Overrides provide a way to replace a package in your dependency tree with
809
+ another version, or another package entirely. These changes can be scoped as
810
+ specific or as vague as desired.</ p >
811
+ < p > To make sure the package < code > foo</ code > is always installed as version < code > 1.0.0</ code > no matter
812
+ what version your dependencies rely on:</ p >
813
+ < pre lang ="json "> < code > {
814
+ "overrides": {
815
+ "foo": "1.0.0"
816
+ }
817
+ }
818
+ </ code > </ pre >
819
+ < p > The above is a short hand notation, the full object form can be used to allow
820
+ overriding a package itself as well as a child of the package. This will cause
821
+ < code > foo</ code > to always be < code > 1.0.0</ code > while also making < code > bar</ code > at any depth beyond < code > foo</ code >
822
+ also < code > 1.0.0</ code > :</ p >
823
+ < pre lang ="json "> < code > {
824
+ "overrides": {
825
+ "foo": {
826
+ ".": "1.0.0",
827
+ "bar": "1.0.0"
828
+ }
829
+ }
830
+ }
831
+ </ code > </ pre >
832
+ < p > To only override < code > foo</ code > to be < code > 1.0.0</ code > when it's a child (or grandchild, or great
833
+ grandchild, etc) of the package < code > bar</ code > :</ p >
834
+ < pre lang ="json "> < code > {
835
+ "overrides": {
836
+ "bar": {
837
+ "foo": "1.0.0"
838
+ }
839
+ }
840
+ }
841
+ </ code > </ pre >
842
+ < p > Keys can be nested to any arbitrary length. To override < code > foo</ code > only when it's a
843
+ child of < code > bar</ code > and only when < code > bar</ code > is a child of < code > baz</ code > :</ p >
844
+ < pre lang ="json "> < code > {
845
+ "overrides": {
846
+ "baz": {
847
+ "bar": {
848
+ "foo": "1.0.0"
849
+ }
850
+ }
851
+ }
852
+ }
853
+ </ code > </ pre >
854
+ < p > The key of an override can also include a version, or range of versions.
855
+ To override
< code > foo
</ code > to
< code > 1.0.0
</ code > , but only when it's a child of
< code > [email protected] </ code > :
</ p >
856
+ < pre lang ="json "> < code > {
857
+ "overrides": {
858
+
859
+ "foo": "1.0.0"
860
+ }
861
+ }
862
+ }
863
+ </ code > </ pre >
864
+ < p > You may not set an override for a package that you directly depend on unless
865
+ both the dependency and the override itself share the exact same spec. To make
866
+ this limitation easier to deal with, overrides may also be defined as a
867
+ reference to a spec for a direct dependency by prefixing the name of the
868
+ package you wish the version to match with a < code > $</ code > .</ p >
869
+ < pre lang ="json "> < code > {
870
+ "dependencies": {
871
+ "foo": "^1.0.0"
872
+ },
873
+ "overrides": {
874
+ // BAD, will throw an EOVERRIDE error
875
+ // "foo": "^2.0.0"
876
+ // GOOD, specs match so override is allowed
877
+ // "foo": "^1.0.0"
878
+ // BEST, the override is defined as a reference to the dependency
879
+ "foo": "$foo",
880
+ // the referenced package does not need to match the overridden one
881
+ "bar": "$foo"
882
+ }
883
+ }
884
+ </ code > </ pre >
803
885
< h3 id ="engines "> engines</ h3 >
804
886
< p > You can specify the version of node that your stuff works on:</ p >
805
887
< pre lang ="json "> < code > {
0 commit comments