
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@nodearchive/nodearchive
Advanced tools
Pack and unpack nar, zip, tar, tgz, tar.gz, and gz archives from one API and CLI for Node.js and Bun.
nodearchive packs and unpacks .nar, .zip, .tar, .tgz, .tar.gz, and
.gz from one package surface for ESM, CommonJS, Bun, and the nar CLI. Use
it when a JavaScript build, release, or vendor-import flow needs one archive
tool instead of a stack of one-format packages.
npm install @nodearchive/nodearchive
pnpm add @nodearchive/nodearchive
yarn add @nodearchive/nodearchive
bun add @nodearchive/nodearchive
Global CLI:
npm install --global @nodearchive/nodearchive
# or
bun add --global @nodearchive/nodearchive
Run once without a global install:
npx @nodearchive/nodearchive pack --help
bunx @nodearchive/nodearchive unpack --help
CLI:
npm i -g @nodearchive/nodearchive
nar --help
nar pack ./src ./app.nar
nar unpack ./incoming.zip ./vendor
Code:
import { pack, unpack } from '@nodearchive/nodearchive'
await pack({ literalPath: ['src'], destinationPath: './app.nar' })
await unpack({ path: './incoming.zip', destinationPath: './vendor' })
CommonJS:
const { pack, unpack } = require('@nodearchive/nodearchive')
async function main() {
const archive = await pack({ blob: 'hello world' })
const restored = await unpack({ blob: archive })
console.log(Buffer.from(restored).toString('utf8'))
}
main()
.nar, .zip, .tar, .tgz, .tar.gz, and .gz.nar, .zip, .tar, .tgz, .tar.gz, and .gzimport and CommonJS require()narimport { pack, unpack } from '@nodearchive/nodearchive'
await pack({
literalPath: ['src', 'package.json'],
destinationPath: './dist/app.nar',
force: true,
})
await unpack({
path: './dist/app.nar',
destinationPath: './out',
force: true,
})
import { pack, unpack } from '@nodearchive/nodearchive'
const archive = await pack({ blob: 'hello world' })
const restored = await unpack({ blob: archive })
console.log(Buffer.from(restored).toString('utf8'))
const { pack, unpack } = require('@nodearchive/nodearchive')
async function main() {
const archive = await pack({ literalPath: ['src'] })
const restored = await unpack({ blob: archive })
console.log(restored.entries.length)
}
main()
import { pack } from '@nodearchive/nodearchive'
await pack({
literalPath: ['src'],
destinationPath: './dist/app.zip',
outFormat: 'zip',
})
await pack({
literalPath: ['src'],
destinationPath: './dist/app.tgz',
})
import { unpack } from '@nodearchive/nodearchive'
await unpack({
path: './vendor/release.tar.gz',
destinationPath: './vendor/release',
force: true,
})
nar pack ./src ./dist/app.nar --passThru
nar pack ./src ./dist/app.zip --outFormat zip --passThru
nar unpack ./dist/app.nar ./out --force --passThru
nar unpack ./incoming.zip ./out --force
nar pack --help
npx @nodearchive/nodearchive pack --help
bunx @nodearchive/nodearchive unpack --help
pack() writes .nar, .zip, .tar, .tgz, .tar.gz, and .gz.unpack() reads .nar, .zip, .tar, .tgz, .tar.gz, and .gz.outFormat selects the output archive type. destinationPath also infers the format from supported extensions..gz output is limited to a single input. update is limited to native .nar output.ArrayBuffer, and SharedArrayBuffer.path uses glob expansion through fast-glob; literalPath stays exact.NodearchiveError codes such as
ARCHIVE_INPUT_REQUIRED, ARCHIVE_INVALID_FORMAT,
ARCHIVE_DESTINATION_EXISTS, and ARCHIVE_ENTRY_PATH_INVALID.coverage/lcov.info and coverage/index.htmlCommand: npm run bench
Environment: Node v22.14.0 on win32 x64
| Benchmark | Result |
|---|---|
pack blob | 3,170.28 ops/s (126.17 ms) |
unpack blob | 3,306.20 ops/s (120.98 ms) |
pack directory | 309.35 ops/s (387.91 ms) |
unpack archive | 4,109.76 ops/s (29.20 ms) |
Results vary by machine.
Apache-2.0
FAQs
Pack and unpack nar, zip, tar, tgz, tar.gz, and gz archives from one API and CLI for Node.js and Bun.
We found that @nodearchive/nodearchive demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.