Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn audit --json returns invalid json #6679

Closed
GaxZE opened this issue Nov 14, 2018 · 2 comments
Closed

yarn audit --json returns invalid json #6679

GaxZE opened this issue Nov 14, 2018 · 2 comments
Assignees
Labels

Comments

@GaxZE
Copy link

GaxZE commented Nov 14, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When I run yarn audit --json multiple root objects are being returned which makes parsing quite difficult as the JSON is invalid.

If the current behavior is a bug, please provide the steps to reproduce.
Running something like:

exec('yarn audit --json', (err, stdout, stderr) => {
  console.log(JSON.parse(stdout));
}

Will return:

SyntaxError: Unexpected token { in JSON at position 1480
    at JSON.parse (<anonymous>)
    at exec (/Users/user/web/project/index.js:62:16)
    at ChildProcess.exithandler (child_process.js:298:5)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Socket.stream.socket.on (internal/child_process.js:380:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:598:12)
✨  Done in 5.95s.

What is the expected behavior?
npm audit --json returns a valid json object for parsing. I would expect the same for yarn audit --json

Please mention your node.js, yarn and operating system version.
node: v10.6.0
yarn: 1.12.3
OS: MacOS Mojave 10.14.1

@ghost ghost assigned rally25rs Nov 14, 2018
@ghost ghost added the triaged label Nov 14, 2018
@rally25rs
Copy link
Contributor

rally25rs commented Nov 14, 2018

The output is in json-lines format, and has been since the --json flag was first introduced in yarn. All the yarn commands output in this same format, not just audit.
There is some discussion in #5021

@ygorbunkov
Copy link

The output is in json-lines format, and has been since the --json flag was first introduced in yarn. All the yarn commands output in this same format, not just audit.
There is some discussion in #5021

Than, based on the link you're referring to, it's neither json, nor json-lines, since the output is wrapped into extra pair of curly braces, which, I believe, causes the above error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants