npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

'npm outdated --json' not always JSON.

What I Wanted to Do

machine parse about one thousand outdated reports. In the event that there are no outdated packages,
NPM should understand the --json bit means…i am expecting json… and should return at least a '{}' or something.

What Happened Instead

If you run npm outdated --json [--long] in a package with no outdated dependencies,
it does not write to stdout.

If someone is using --json, they are expecting json in the stdout. a zero-length string is not a valid JSON string.

Reproduction Steps

go to literally any directory with a package.json that is fully up-to-date. run npm outdated --json.

'' is not a valid json string. Mind you, '""' is, as is '{}'. But an empty string cannot be parsed as json,
though some implementations (like jq) are smart enough to figure it out.


Platform Info

npm version 6.7.0

This does indeed seem like a very good first contrib! I’ve tagged it as such. Thank you!