You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ecb02a8
Browse filesBrowse the repository at this point in the historyBrowse files
npm 12.0.0 breaks downstream updaters by returning nested arrays for
`npm view <pkg> versions --json`.
## The bug
On npm 12.0.0, a single array-valued field is wrapped in the outer
results array:
```
$ npm view abbrev versions --json
[["1.0.3","1.0.4", ...]] # should be ["1.0.3","1.0.4", ...]
```
This happens in `lib/commands/view.js` `#packageOutput`: for a
single-field query it maps to `res.map(m => m[first[0]])`, and when that
field's value is itself an array (e.g. `versions`), it gets
double-wrapped.
## The fix
Return a sole array-valued JSON result directly instead of adding a
second result wrapper. Existing output shapes are preserved:
- scalar and object results still return in an array (`["1.0.0"]`,
`[{...}]`)
- multiple matching versions keep the result boundary (`[[...],[...]]`)
- a single array-valued result is returned directly
(`["1.0.0","1.0.1"]`)
Docs and tests updated to cover flat array, nested array,
object-wrapper, workspace, and multi-match cases.
Co-authored-by: Martin Ruiz <[email protected]>
Co-authored-by: Copilot <[email protected]>
0 commit comments