Skip to content

npm Client

A TypeScript client for the npm registry: whoami and the latest version of a package. It is what the npm plugin builds the registry capability on.

Terminal window
pnpm add @theholocron/npm-client
import { createNpmClient } from "@theholocron/npm-client";
const npm = createNpmClient({ token: process.env.NPM_TOKEN! });
// Who is the token? GET /-/whoami
const { username } = await npm.whoami();
// The latest version of a package, or undefined when the registry does not have it (a 404).
// A scoped name is written @scope%2Fname in the request.
const latest = await npm.packages.latestVersion("@theholocron/cli");

npm does not expose a token’s creation date, expiry or permissions to the token itself, so the client has no call for them.

The full API reference is generated from the package’s TSDoc comments.