# libnpmpack

> Programmatic API for the bits behind npm pack

Latest version **10.0.2** (published 2026-07-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install libnpmpack
pnpm add libnpmpack
yarn add libnpmpack
bun add libnpmpack
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 10.0.2 |
| Published | 2026-07-29 |
| First published | 2020-03-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^22.22.2 \|\| ^24.15.0 \|\| >=26.0.0 |
| Dependencies | 4 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10110 |
| Author | GitHub Inc. |
| Maintainers | saquibkhan, npm-cli-ops, reggi |

## Links

- npm: https://www.npmjs.com/package/libnpmpack
- Repository: https://github.com/npm/cli
- Homepage: https://npmjs.com/package/libnpmpack
- Issues: https://github.com/npm/libnpmpack/issues
- npm.io page: https://npm.io/package/libnpmpack

## Dependencies (4)

- [pacote](https://npm.io/package/pacote.md) ^22.0.0
- [npm-package-arg](https://npm.io/package/npm-package-arg.md) ^14.0.0
- [@npmcli/arborist](https://npm.io/package/@npmcli/arborist.md) ^10.0.2
- [@npmcli/run-script](https://npm.io/package/@npmcli/run-script.md) ^11.0.0

## Recent versions

- 10.0.2 (latest) — 2026-07-29
- 9.1.13 (backport) — 2026-08-26
- 10.0.0-pre.2 (prerelease) — 2026-06-29
- 9.1.12 — 2026-07-29
- 10.0.1 — 2026-07-10
- 10.0.0 — 2026-07-08
- 9.1.11 — 2026-06-29
- 10.0.0-pre.1 — 2026-06-19
- 9.1.10 — 2026-06-11
- 9.1.9 — 2026-05-27
- 10.0.0-pre.0.0 — 2026-05-20
- 9.1.8 — 2026-05-20
- 9.1.7 — 2026-05-06
- 9.1.6 — 2026-04-22
- 8.0.5 — 2026-03-27
- … 84 more at https://npm.io/package/libnpmpack/versions

## README

# libnpmpack

[![npm version](https://img.shields.io/npm/v/libnpmpack.svg)](https://npm.im/libnpmpack)
[![license](https://img.shields.io/npm/l/libnpmpack.svg)](https://npm.im/libnpmpack)
[![CI - libnpmpack](https://github.com/npm/cli/actions/workflows/ci-libnpmpack.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/ci-libnpmpack.yml)

[`libnpmpack`](https://github.com/npm/libnpmpack) is a Node.js library for
programmatically packing tarballs from a local directory or from a registry or github spec. If packing from a local source, `libnpmpack` will also run the `prepack` and `postpack` lifecycles.

## Table of Contents

* [Example](#example)
* [Install](#install)
* [API](#api)
  * [`pack()`](#pack)

## Example

```js
const pack = require('libnpmpack')
```

## Install

`$ npm install libnpmpack`

### API

#### <a name="pack"></a> `> pack(spec, [opts]) -> Promise`

Packs a tarball from a local directory or from a registry or github spec and returns a Promise that resolves to the tarball data Buffer, with from, resolved, and integrity fields attached.

If no options are passed, the tarball file will be saved on the same directory from which `pack` was called in.
 
`libnpmpack` uses [`pacote`](https://npm.im/pacote).
Most options are passed through directly to that library, so please refer to
[its own `opts`
documentation](https://www.npmjs.com/package/pacote#options)
for options that can be passed in.

##### Examples

```javascript
// packs from cwd
const tarball = await pack()

// packs from a local directory
const localTar = await pack('/Users/claudiahdz/projects/my-cool-pkg')

// packs from a registry spec
const registryTar = await pack('abbrev@1.0.3')

// packs from a github spec
const githubTar = await pack('isaacs/rimraf#PR-192')
```

---
_Source: https://npm.io/package/libnpmpack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
