Skip to content

fix(npm): return the real value for info field; name the missing program - #1200

Merged
horza-bora merged 1 commit into
mainfrom
fix/npm-install-info-run
Oct 19, 2026
Merged

horza-bora merged 1 commit into
mainfrom
fix/npm-install-info-run

Conversation

@Dave-London

Copy link
Copy Markdown
Owner

What changed

#1164: info with field. npm view <pkg> <field> --json prints only that field's value: "2.0.8", an object, or nothing at all. parseInfoJson read name and version off that value and fell back to "unknown" / "0.0.0". So an agent asking for the latest version got a confident wrong answer.

  • With field, the result is now { name, field, value }. value is omitted when the package doesn't set the field, and version / description are now optional in the schema.
  • parseInfoJson throws on output that isn't a JSON object, instead of filling in placeholders.
  • Smoke S9 mocked a full metadata object for a field query, which npm never returns. It now uses npm's real output.

#1093 diagnostics. When cmd.exe reports 'x' is not recognized while running a .cmd wrapper, and x isn't the wrapper itself, the error now names x and the wrapper that needed it. #1093 itself doesn't reproduce on current code (details on the issue), so this PR only refers to it.

Fixes #1164. Refs #1093.

How it was tested

  • Real npm output captured for proxy-addr: version gives "2.0.8", engines gives an object, and a nonexistent field gives nothing.
  • End to end, old build against new, for info proxy-addr with fields version, engines and funding. The Aug 19 build returns {name:"unknown",version:"0.0.0"} for all three. This branch returns the real values, e.g. {name:"proxy-addr",field:"engines",value:{node:">= 0.10"}}.
  • info-search.test.ts 35 of 35 (5 new). Shared runner.test.ts 95 of 95, plus a new Windows test for the message. Smoke 2337 of 2337. tsc, eslint and prettier are clean.

…ogram

`npm view <pkg> <field> --json` prints a bare value ("2.0.8", an object, or
nothing), and parseInfoJson read name/version off it, falling back to
"unknown"/"0.0.0" (#1164).

- With `field`, info returns { name, field, value }; value is omitted when
  the package does not set the field. version/description are optional.
- parseInfoJson rejects output that is not a JSON object instead of filling
  placeholders.
- Smoke S9 mocked a full metadata object for a field query; it now uses
  npm's real output.

shared: when cmd.exe reports "'x' is not recognized" for a .cmd wrapper and
x is not the wrapper, the error names x and the wrapper that needed it. This
came out of #1093, which does not reproduce on current code.

Fixes #1164
Refs #1093

@horza-bora horza-bora left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: info field returns the real value (verified old vs new end to end), placeholders rejected, clearer not-found message with a Windows test. CI green.

@horza-bora
horza-bora merged commit 3ff25dc into main Oct 19, 2026
11 checks passed
@horza-bora
horza-bora deleted the fix/npm-install-info-run branch October 19, 2026 10:18
@pare-ci-bot pare-ci-bot Bot mentioned this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pare-npm info: field returns {name:"unknown", version:"0.0.0"} instead of the field value

2 participants