Registry / devops / packument

packument

JSON →
library2.0.0jsnpmunverified

A Node.js library for fetching npm registry metadata (packuments) for a given package name. Version 2.0.0 supports scoped packages, private registries, and both abbreviated and full metadata formats. The API is callback-based with a factory pattern for preconfiguration. It is lightweight with zero dependencies. Useful for tools that need to inspect package metadata without relying on npm CLI. Maintained by Vincent Weevers.

npm install packument
INSTALL
IMPORT
SIG · PACKUMENT
P
packument
devopsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

packument
const packument = require('packument')
import packument from 'packument'
This package is CommonJS-only; there is no ESM module. Named exports are also not supported.
factory
const packument = require('packument').factory({ full: true })
const { factory } = require('packument')
factory is a method on the default export, not a named export. To preconfigure, use .factory() after require.
callback
packument('levelup', (err, result) => { ... })
packument('levelup').then(...)
packument does not return a Promise; it expects a callback. Use promisify if needed.

Fetches the packument for a given package name (e.g., 'express') and prints the latest version and its license.

const packument = require('packument'); const packageName = process.env.PACKAGE_NAME || 'express'; packument(packageName, (err, result) => { if (err) { console.error('Error fetching packument:', err); return; } const latestVersion = result['dist-tags'].latest; const license = result.versions[latestVersion].license; console.log(`Package: ${packageName}`); console.log(`Latest version: ${latestVersion}`); console.log(`License: ${license}`); });
Debug
Known issues
gotchaThe abbreviated response does not contain all metadata (e.g., readme, _rev). If you need those, set opts.full = true.
fix
Require full metadata by passing { full: true } as options.
affects: >=1.0.0
gotchaThis library is callback-based and does not return a Promise. Using async/await without promisifying will fail.
fix
Wrap with util.promisify or use a promise-based alternative like pacote.
affects: >=1.0.0
gotchaThe library makes HTTP requests to the npm registry. In environments with network restrictions, it may time out or fail.
fix
Set appropriate proxy settings or configure headers with custom agent.
affects: >=1.0.0
deprecatedThe callback signature includes response headers as third argument, but this feature is not fully documented and may be removed.
fix
Check the response headers in opts via the 'response' event if needed.
affects: >=2.0.0
Errors
Common errors & fixes
packument is not a function
Using import instead of require in a CommonJS environment, or incorrect import path.
fix
Use const packument = require('packument');
Error: connect ETIMEDOUT
Network timeout while reaching npm registry.
fix
Check network connectivity, or configure a custom timeout and retry logic.
TypeError: packument is not iterable
Expecting an array or promise from packument; it returns undefined and uses callback.
fix
Use callback or promisify the function.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
packument — npm install packument · libregistry