sindresorhus / np

A better `npm publish`
MIT License
7.56k stars 299 forks source link

Fix json output in some npm version #737

Closed voxpelli closed 8 months ago

voxpelli commented 8 months ago

I was having an issue with np on npm version 10.5.0 and when digging into it I found that the npm pack command was outputting some "helpful" notes prior to the JSON.

I tried adding a --silent to the command, and that fixed remove the "helpfulness".

Apart from doing that, this PR also wraps the original exception in a new error that explains what kind of JSON-parsing that's failing – as that can make it a bit more easy to understand why it suddenly started failing.

My npm version 10.5.0:

❯ npm pack --dry-run --json                                 

> @voxpelli/typed-utils@1.3.0 prepare
> husky

[
  {
    "id": "@voxpelli/typed-utils@1.3.0",
    "name": "@voxpelli/typed-utils",