Skip to content

Commit 4850639

Browse files
Max Blackowlstronaut
authored andcommitted
docs(package-json): add examples for replacing dependencies with forks in overrides
1 parent 4864dd4 commit 4850639

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,53 @@ To make this limitation easier to deal with, overrides may also be defined as a
939939
}
940940
```
941941
942+
#### Replacing a dependency with a fork
943+
944+
You can replace a package with a different package or fork using several methods:
945+
946+
**Using the `npm:` prefix to replace with a different package name:**
947+
948+
```json
949+
{
950+
"overrides": {
951+
"package-name": "npm:@scope/[email protected]"
952+
}
953+
}
954+
```
955+
956+
**Using a GitHub repository (supports branches, tags, or commit hashes):**
957+
958+
```json
959+
{
960+
"overrides": {
961+
"package-name": "github:username/repo#branch-name"
962+
}
963+
}
964+
```
965+
966+
**Using a local file path:**
967+
968+
```json
969+
{
970+
"overrides": {
971+
"package-name": "file:../local-fork"
972+
}
973+
}
974+
```
975+
976+
These replacement methods work for both top-level overrides and nested overrides.
977+
For example, to replace a transitive dependency with a fork:
978+
979+
```json
980+
{
981+
"overrides": {
982+
"parent-package": {
983+
"vulnerable-dep": "github:username/patched-fork#v2.0.1"
984+
}
985+
}
986+
}
987+
```
988+
942989
### engines
943990
944991
You can specify the version of node that your stuff works on:

0 commit comments

Comments
 (0)