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 dependenciesCommon 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 publishRelated guides
npm "409 Conflict" on Publish - Fix Duplicate/Concurrent Publish in CIFix npm "E409 409 Conflict - PUT" when publishing in CI - a version already exists or two release jobs raced…
npm dist-tag: Usage, Options & Common Errorsnpm dist-tag adds, removes, and lists the named tags (latest, beta, next) that map to package versions. Usage…
npm search: Usage, Options & Common Errorsnpm search finds packages in the registry by keyword. Usage, JSON output, and why it can fail or hang against…