Skip to content
Latchkey

npm view: Usage, Options & Output

Query registry metadata for any package.

npm view (alias npm info) fetches metadata about a package from the registry - every published version, dist-tags, dependencies, and arbitrary package.json fields.

What it does

Reads the registry document for a package and prints requested fields. With no field it prints a summary; with a field path it prints just that value. --json gives machine-readable output for scripting in CI.

Common usage

Terminal
npm view react versions --json     # all published versions
npm view react version             # latest version
npm view react dist-tags           # tag -> version map
npm view lodash dependencies

Common CI pattern: guard against double-publish

A release pipeline re-runs and fails with E409 because the version is already published. Before publishing, query the registry with npm view and skip if the version already exists.

.github/workflows/release.yml
if npm view my-pkg@${VERSION} version >/dev/null 2>&1; then
  echo "already published"; exit 0
fi
npm publish

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →