Registry / devops / libnpmfund

libnpmfund

JSON →
library7.0.19jsnpmunverified

The `libnpmfund` package offers a dedicated programmatic API for interfacing with the `npm fund` command, enabling developers to integrate dependency funding information retrieval directly into their applications. As per the provided metadata, its current stable version is 7.0.19. This package is an integral component of the broader npm CLI ecosystem, undergoing regular maintenance and receiving updates in alignment with new npm CLI releases, which implies an active and responsive development cycle. Its primary advantage lies in providing a structured, JavaScript-native interface to access the aggregated funding data, which is typically presented by the `npm fund` CLI. This capability is crucial for building automated tools, dashboards, or custom reporting systems that need to analyze or display dependency funding without relying on external process execution or parsing CLI output. It explicitly depends on `@npmcli/arborist` for robust dependency graph traversal and analysis.

npm install libnpmfund
INSTALL
IMPORT
SIG · LIBNPMFUND
L
libnpmfund
devopsjavascriptv7.0.19
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fund
import { fund } from 'libnpmfund'
const fund = require('libnpmfund')
The primary function to retrieve funding information. Uses ESM by default due to modern Node.js engine requirements. Avoid direct CommonJS require if your environment is ESM-first.
FundOptions
import type { FundOptions } from 'libnpmfund'
Type import for configuration options passed to the `fund` function, enabling type-safe usage in TypeScript projects.
FundResult
import type { FundResult } from 'libnpmfund'
Type import for the structured result object returned by the `fund` function, providing strong typing for the funding data.

This quickstart demonstrates how to programmatically retrieve funding information for a JavaScript/TypeScript project's dependencies using `libnpmfund`. It calls the `fund` function with the current project path and requests JSON output, then logs the structured funding data to the console, providing an insight into how maintainers can be supported programmatically.

import { fund } from 'libnpmfund'; import path from 'path'; async function getFundingInfo(projectPath: string) { try { console.log(`Attempting to retrieve funding information for: ${projectPath}`); // The `fund` function typically needs a path and an options object. // Setting `json: true` is crucial for programmatic consumption to get structured data. const result = await fund(projectPath, { json: true, // Other options can be passed, e.g., to only include production dependencies: // production: true, // or for a specific workspace: // workspace: 'my-workspace-name' }); if (result && Object.keys(result).length > 0) { console.log('Successfully retrieved funding information:'); // Log the result with full depth to see the entire structure console.dir(result, { depth: null, colors: true }); } else { console.log('No funding information found for this project or its dependencies.'); } return result; } catch (error) { console.error(`Failed to get funding info for ${projectPath}:`, error); throw error; // Re-throw to propagate the error } } // Example usage: Get funding for the current project directory where the script is run const currentProjectPath = path.resolve('.'); getFundingInfo(currentProjectPath) .then(() => console.log('\nFunding info retrieval process complete.')) .catch(err => console.error('\nAn unhandled error occurred during quickstart execution:', err));
Debug
Known issues
breakingMajor version updates for `libnpmfund` (e.g., from v6 to v7) typically introduce breaking changes in API signatures, available options, or the structure of returned data. Always consult the official release notes when upgrading.
fix
Review the official npm CLI GitHub repository release notes or `libnpmfund`'s changelog for specific breaking changes. Adapt your code to the new API as documented.
affects: >=6.0.0
gotchaThe package has strict Node.js engine requirements (`^20.17.0 || >=22.9.0`). Using an older Node.js version than specified in the `engines` field will result in runtime errors.
fix
Ensure your Node.js environment meets the specified engine requirements. Update Node.js to a compatible version using a version manager like `nvm` or `volta`.
affects: >=7.0.0
gotchaAs a component of the `npm/cli` ecosystem, `libnpmfund` heavily relies on `@npmcli/arborist` for core dependency tree resolution logic. Updates or changes in Arborist's behavior can indirectly impact `libnpmfund`'s functionality, performance, or output.
fix
When debugging issues related to dependency resolution or tree traversal with `libnpmfund`, consider checking the `@npmcli/arborist` package's release notes for relevant changes, known issues, or potential workarounds.
affects: >=6.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/libnpmfund/index.js from ... is not supported.
`libnpmfund` is primarily distributed as an ES Module (ESM). Attempting to import it using CommonJS `require()` syntax directly will result in this error in modern Node.js environments.
fix
Migrate your import statements to use ESM syntax: `import { fund } from 'libnpmfund';`. If your project must remain CommonJS, consider using dynamic import `await import('libnpmfund')`.
TypeError: fund is not a function
This error typically indicates that the `fund` export was not correctly imported, or the module itself failed to load. This can happen due to incorrect import paths, a corrupted `node_modules` installation, or a typo in the symbol name.
fix
Verify your import statement: `import { fund } from 'libnpmfund';`. Ensure `libnpmfund` is correctly installed via `npm install libnpmfund` and try deleting `node_modules` and `package-lock.json` before reinstalling if issues persist.
TypeError: The "path" argument must be of type string. Received undefined
The `fund` function requires a valid project path (a string) as its first argument. Passing `undefined`, `null`, or any non-string value will trigger this type error.
fix
Ensure that the first argument passed to `fund()` is a string representing the absolute or relative path to the project directory you wish to analyze. For example, `fund(path.resolve('./my-project'))` or `fund('.')`.
Upgrade
Version history
7.0.19latest on npm
Audit
Dependencies
@npmcli/arboristrequiredCore dependency for traversing and analyzing the dependency tree to identify funding sources.
Agent activity
2 hits · last 30 days
node
2
Resources