Search code examples
node.jsnpmnpm-install

How to output regular ASCII from "npm install" as opposed to the pretty-formatted output given by default?


When executing "npm install", I get a bunch of prettily-formatted output in the terminal. This includes changing cursor placement, cursor backstep with erase, line drawings, lots of colored text, etc.

I would like to get just regular ASCII output in the terminal without any of this formatting (think of how normal output from console.log() looks like). I am trying to set up a logging system for my project, so having just the text output is needed for easy and efficient parsing.

In the case that such an option doesn't exist, would the next best option be to reformat the output myself? Is there an external tool that already does this?

I've already tried looking at the npm install documentation, but I couldn't find any flag that would switch the "mode" of the output.


Solution

  • In case anyone else comes across this, the best solution I've found is a combination of some npm install flags and sed:

    npm install --no-progress --no-color | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"