Search code examples
yarnpkg

What is the best way to save the results of `yarn audit` to a text file?


I have tried using yarn-audit-html but it outputs a .html file.

I would like the output audit table results from the audit in a text or json file.

Here is the data I am looking for: enter image description here

Note: copy/paste from the terminal is not an option because of the # of results that are returned.


Solution

  • You can redirect the output of yarn audit into a file on the command line.

    yarn audit > audit-output.txt
    

    The default output of audit contains lots of color sequences that make it difficult to read but could probably be stripped out in post-processing. To get the output as JSON, add the --json flag.

    yarn audit --json > audit-output.json