The npm fund command is more than just a way to see where your dependencies get their money; it’s a direct line to the economic health of the open-source ecosystem you’re relying on.

Let’s see it in action. Imagine you have a project with a few dependencies.

{
  "name": "my-cool-app",
  "version": "1.0.0",
  "dependencies": {
    "express": "^4.17.1",
    "lodash": "^4.17.21",
    "react": "^17.0.2"
  }
}

Running npm fund in your project directory might produce output like this:

my-cool-app@1.0.0
├── express@4.17.1
│ ├── body-parser@1.19.0
│ │ ├── bytes@3.1.0
│ │ ├── debug@4.3.1
│ │ ├── depd@1.1.2
│ │ ├── http-errors@1.7.2
│ │ │ ├── inherits@2.0.4
│ │ │ ├── setprototypeof@1.1.3
│ │ │ └── status-codes-js@2.1.0
│ │ ├── iconv-lite@0.4.24
│ │ │ └── safer-buffer@2.1.2
│ │ ├── merge-descriptors@1.0.1
│ │ ├── methods@1.1.2
│ │ ├── parseurl@1.3.3
│ │ ├── range-parser@1.2.0
│ │ ├── serve-static@1.14.1
│ │ │ ├── escape-html@1.0.3
│ │ │ ├── parseurl@1.3.3
│ │ │ └── send@0.17.1
│ │ │   ├── debug@4.3.1
│ │ │   ├── ms@2.1.2
│ │ │   ├── mime@1.6.0
│ │ │   └── statuses@1.5.0
│ │ ├── utils-merge@1.0.2
│ │ └── vary@1.1.2
├── lodash@4.17.21
└── react@17.0.2

This is a hierarchical view of your project’s dependency tree, showing each package and its direct dependents. For each package, if funding information is available, npm fund will display it.

The problem npm fund aims to solve is the inherent fragility of the open-source software supply chain. For decades, much of the world’s critical software infrastructure has been built and maintained by volunteers or by individuals and companies who receive little to no direct financial compensation. This creates a risk: if a key maintainer burns out, moves on, or simply can’t afford to continue, a vital piece of software can become unmaintained, leading to security vulnerabilities or breaking changes when it’s no longer compatible with newer systems. npm fund attempts to mitigate this by making the funding needs of these packages transparent.

When you run npm fund, npm consults the package.json files of each package in your dependency tree. Specifically, it looks for a funding field. This field can take several forms:

  • A string URL: {"funding": "https://opencollective.com/expressjs"}
  • An object with a URL and a type: {"funding": {"type": "github", "url": "https://github.com/sponsors/expressjs"}}
  • An array of objects: This allows for multiple funding sources.

If a funding field exists, npm fund will display it, often indicating the type of funding (e.g., "github", "opencollective", "patreon", "buymeacoffee") and the associated URL.

The actual "magic" happens when npm traverses your installed modules. It reads the package.json for each, and if a funding key is present, it registers that information. When you run npm fund, it then aggregates and displays this information, starting from your top-level project and recursively showing it for each dependency.

The most surprising true thing about npm fund is that most packages don’t have funding information declared. This isn’t necessarily a sign of neglect, but it highlights the vast, uncompensated labor that underpins much of the JavaScript ecosystem. A package appearing in npm fund without any funding details means its maintainers haven’t explicitly stated how they wish to be supported, or they haven’t configured their package.json to indicate this. It’s a quiet testament to the goodwill and volunteer effort that keeps things running.

To make your own projects more transparent, you can add a funding property to your package.json. For example:

{
  "name": "my-library",
  "version": "1.0.0",
  "funding": {
    "type": "github",
    "url": "https://github.com/sponsors/myusername"
  },
  "dependencies": {
    // ...
  }
}

This tells users of your library how they can contribute financially if they wish.

The next step after understanding package funding is to explore how to contribute to those packages, whether through financial means or by improving the documentation or code.

Want structured learning?

Take the full Npm course →