8

I am using the following command to look up versions of the packages that I have.

npm view <packagename> versions

The result that I get back is as follows

  '2.4.0-2016-10-06-6743',
  '2.4.0-2016-10-07-6750',
  '2.4.0-2016-10-07-6751',
  '2.4.0-2016-10-07-6754',
  '2.4.0-2016-10-07-6755',
  '2.4.0-2016-10-10-6763',
  '2.4.0-2016-10-11-6770',
  '2.4.0-2016-10-11-6790',
  '2.4.0-2016-10-12-6799',
  '2.4.0-2016-10-12-6800',
  '2.4.0-2016-10-13-6806',
  '2.4.0-2016-10-13-6807',
  '2.4.0-2016-10-13-6808',
  '2.4.0-2016-10-14-6810',
  ... 37 more items ]

I want to get all the results as you can see there are 37 more items which are not shown.

How can I get all the results.

I am using windows command prompt as well as the gitbash tool on windows.

Robbie
  • 18,750
  • 4
  • 41
  • 45
krv
  • 2,830
  • 7
  • 40
  • 79
  • Possible duplicate of [Log over 100 array items in node](https://stackoverflow.com/questions/41669039/log-over-100-array-items-in-node) – Evan Carroll Jan 17 '19 at 02:01

1 Answers1

16

try adding --json to the command

npm view <packagename> versions --json

This is a change to the behavior of util.inspect() in newer versions of Node.js (I'm guessing – this isn't behavior that the npm CLI team changed). If you want to get the full list, and also want to ensure that it's parseable, just add --json to the command, to get the raw output of JSON.stringify() applied to that piece of the package's metadata.

https://github.com/npm/npm/issues/13376#issuecomment-232525623

Robbie
  • 18,750
  • 4
  • 41
  • 45
  • I'm not happy that they made assumptions about formatting, but at least it prints reasonably. – Joshua Drake Sep 26 '17 at 01:28
  • @JoshuaDrake they're not really making any assumptions about the format - and not saying "if you want the full output you must embrace json" - its just turns out that `JSON.stringify()` was not affected by the same behaviour change as `util.inspect()` - so you can use `--json` it as a workaround for getting the full list – Robbie May 09 '18 at 20:51