yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒

Home Page:https://yarnpkg.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug?]: `yarn npm audit --json` outputs invalid JSON

marksy opened this issue · comments

Self-service

  • I'd be willing to implement a fix

Describe the bug

Yarn v4 (4.0.1 through to stable, as of writing) where running yarn npm audit --json outputs invalid JSON (Yarn v4.0.0 and v3.x output valid JSON)

To reproduce

https://github.com/marksy/yarn-audit-json-issue

Environment

System:
  OS: macOS 14.5
  CPU: (12) arm64 Apple M2 Max
Binaries:
  Node: 20.12.2 - /private/var/folders/k2/m0m6z1jn77182kybf_6yrql80000gq/T/xfs-beb518a3/node
  Yarn: 4.3.1 - /private/var/folders/k2/m0m6z1jn77182kybf_6yrql80000gq/T/xfs-beb518a3/yarn
  npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm

Additional context

No response

Is this related to maybe #5830 or #5824?

All Yarn commands currently output NDJSON when the --json flag is set; is that what you're referencing?

Yeah.

It used to output as valid JSON, as I’ve been using yarn-audit-html with it for a while.

When did Yarn change to NDJSON?

I think I’ve run into the same / similar issue here
#5781

See #5781 (comment):

Note that there's a bug in the output which I fixed in #5833. The format will be slightly different in 4.0.1 (will release in a couple of hours).

And #5833:

Fixes #5830 - The --json output was printing the raw registry output, not the filtered tree

Hi! 👋

It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it.