Skip to content

Commit a25c489

Browse files
committed
docs: add section on peerDependenciesMeta field in package.json (fixes npm#1247)
1 parent bd2721d commit a25c489

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Diff for: docs/content/configuring-npm/package-json.md

+24
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,30 @@ the host package's major version will break your plugin. Thus, if you've worked
718718
with every 1.x version of the host package, use `"^1.0"` or `"1.x"` to express
719719
this. If you depend on features introduced in 1.5.2, use `">= 1.5.2 < 2"`.
720720

721+
### peerDependenciesMeta
722+
723+
When a user installs a your package, npm will emit warnings if packages specified in `peerDependencies` are not already installed. The `peerDependenciesMeta` field serves to provide npm more information on how your peer dependencies are to be used. Specifically, it allows peer dependencies to be marked as optional.
724+
725+
For example:
726+
727+
```json
728+
{
729+
"name": "tea-latte",
730+
"version": "1.3.5",
731+
"peerDependencies": {
732+
"tea": "2.x",
733+
"soy-milk": "1.2"
734+
},
735+
"peerDependenciesMeta": {
736+
"soy-milk": {
737+
"optional": true
738+
}
739+
}
740+
}
741+
```
742+
743+
Marking a peer dependency as optional ensures npm will not emit a warning if the `soy-milk` package is not installed on the host. This allows you to integrate and interact with a variety of host packages without requiring all of them to be installed.
744+
721745
### bundledDependencies
722746

723747
This defines an array of package names that will be bundled when publishing

0 commit comments

Comments
 (0)