Skip to content

Use bun with Pier

Bun’s package manager (bun add, bun install) speaks the standard npm registry protocol and reads .npmrc — identical to npm. The two interesting bits are:

  • Abbreviated packument — bun sends Accept: application/vnd.npm.install-v1+json by default. Pier returns a leaner JSON payload (no README, no historical times), making installs noticeably snappier on large packages.
  • Always sends bearer. Like npm and pnpm, bun sends auth on every request — no always-auth=true workaround needed.
.npmrc
registry=https://YOUR-PIER-HOST/registry/npm/
//YOUR-PIER-HOST/registry/npm/:_authToken=pier_npm_…
always-auth=true

always-auth=true is harmless for bun. Keep it so the same .npmrc also works for yarn 1 if you ever need it.

Terminal window
bun install
bun add left-pad
bun add @your-org/internal-lib
bun add -d typescript # devDependency
Terminal window
bun publish

Bun supports bun publish from version 1.1+. It uses the same wire format every npm CLI uses (CouchDB-style PUT with _attachments).

Bun doesn’t have its own browser login flow. Use npm login --auth-type=web against Pier — bun reads the same .npmrc:

Terminal window
npm login --auth-type=web --registry=https://YOUR-PIER-HOST/registry/npm/

The abbreviated packument strips fields not needed for install resolution:

FieldFullAbbreviated
name
dist-tags
versions[*]full manifestonly install-time fields
versions[*].dist.{tarball,integrity}
versions[*].readme
versions[*].time
time (history map)

For popular packages (next, react, etc.) the abbreviated form is 5–10× smaller. Pier serves both; the choice is driven by the Accept header.

bun versionStatusNotes
latest (1.x)Tested in pier-tests matrix against current stable

Pin via packageManager if you want lockstep behavior:

{
"packageManager": "[email protected]"
}
  • error: not found: <pkg> — upstream proxy off + package not privately published. Enable proxy.
  • error: Failed to authenticate — token missing or revoked. Mint a fresh one.
  • error: file not found on a scoped package — the URL-encoding for @scope/name might be mangled by an intermediate proxy. Test the raw fetch: curl -H "Authorization: Bearer pier_npm_…" https://pier-host/registry/npm/@scope%2Fname — should return packument JSON.