Skip to content

Fix package.json hover metadata broken in npm 12+ - #327951

Open
Guilherme Menezes Magalhães (guimmd2) wants to merge 1 commit into
microsoft:mainfrom
guimmd2:fix/npm12-view-array
Open

Fix package.json hover metadata broken in npm 12+#327951
Guilherme Menezes Magalhães (guimmd2) wants to merge 1 commit into
microsoft:mainfrom
guimmd2:fix/npm12-view-array

Conversation

@guimmd2

Copy link
Copy Markdown

Fixes #327228

Description

npm 12 changed npm view --json to always return an array [{...}] instead of {...}. Handle both formats by checking Array.isArray.

Validation

Manually tested by building VS Code from source and hovering over package.json dependencies:

  • With npm 11: all metadata (description, latest version, homepage) displayed correctly
image
  • With npm 12: same, all metadata now displays correctly
image

Both versions work after the fix.

npm 12 changed npm view --json to always return an array [{...}]
instead of {...}. Handle both formats by checking Array.isArray.

Fixes microsoft#327228
Copilot AI review requested due to automatic review settings July 29, 2026 03:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates npm package metadata parsing to support npm 12’s array response while retaining compatibility with earlier versions.

Changes:

  • Detects array-form npm view --json output.
  • Extracts the single package metadata object.

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.

npm view --json returns an array since npm 12 and breaks hover metadata in package.json

3 participants