From d6222a8ec3b9cfb4bb88a6342fc9ebc553273098 Mon Sep 17 00:00:00 2001 From: ysknsid25 Date: Wed, 4 Nov 2026 22:00:29 +0900 Subject: [PATCH] docs: clarify validation rules for the funding field Signed-off-by: ysknsid25 --- .../content/configuring-npm/package-json.md | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/lib/content/configuring-npm/package-json.md b/docs/lib/content/configuring-npm/package-json.md index 56724afe699ab..4deed5ea5ce67 100644 --- a/docs/lib/content/configuring-npm/package-json.md +++ b/docs/lib/content/configuring-npm/package-json.md @@ -258,9 +258,27 @@ You can specify an object containing a URL that provides up-to-date information } ``` +Each funding source must follow these rules: + +* `url` is required and must be a valid `http:` or `https:` URL with a host. + Other protocols, such as `mailto:`, are not valid. +* `type` is optional and can be any string. + npm does not check it against a list of known values. + It is only shown in the message printed by `npm fund `, for example `patreon funding available at the following URL`. +* An array must contain only objects and string URLs. + Nested arrays are not valid. + +When `funding` is an array, every entry must be valid. +If any entry in the array is invalid, the whole `funding` field of that dependency is ignored when `npm fund` lists funding sources. +The dependency is also not counted in the "packages are looking for funding" message shown after `npm install`. + Users can use the `npm fund` subcommand to list the `funding` URLs of all dependencies of their project, direct and indirect. +In this list, only the first valid funding source of each package is shown, so put the most important one first. +Use `npm fund --json` to see all funding sources. + A shortcut to visit each funding URL is also available when providing the project name such as: -`npm fund ` (when there are multiple URLs, the first one will be visited) +`npm fund `. +When there are multiple valid URLs, npm lists them and asks you to choose one with the [`--which` config](/using-npm/config#which), for example `npm fund --which=1`. ### files