pnpm view: From npm Pass-through to Native Implementation

Scritto da Alessio il 27/03/2026

Problem

pnpm's view command was passing through to npm's CLI. This meant an extra process, no support for corporate proxies, broken URL encoding for scoped packages, and auth headers not forwarded to private registries.

Solution

I implemented pnpm view natively in @pnpm/inspection.commands.

Key changes:

  • Reused pickPackageFromMeta from npm-resolver, eliminating duplicate fetches
  • Fixed URL encoding for scoped packages (@scope/pkg)
  • Forwarded auth headers, proxy config, SSL settings through proper Config options
  • Added support for --json, --ext, --tag flags

The refactoring shared version resolution logic with the npm-resolver instead of reimplementing tag/range/version matching.

Result

The view command now works correctly with private registries behind corporate proxies. HTTP fetches reduced from 2 to 1 per query.

Commit: pnpm/pnpm@2c90d406
PR: #11064