Pm2: chalk doesn't work in pm2 logs

Created on 27 Oct 2015  路  5Comments  路  Source: Unitech/pm2

I use chalk to styling my console, but with pm2 it doesn't work
my code is like this:

  console.log(chalk.green('this is a chalk color string'));

run it with node or pm2 command,in pm2 chalk doesn't take any effection


Most helpful comment

Just try:

{
  "apps": [
    {
      "[SOME]":"[CONFIGS]",
      "args": [
        "--color"
      ]
    }
  ]
}

or

$ pm2 start myapp.js -- --color

All 5 comments

Just try:

{
  "apps": [
    {
      "[SOME]":"[CONFIGS]",
      "args": [
        "--color"
      ]
    }
  ]
}

or

$ pm2 start myapp.js -- --color

@Tjatse Thank you

Where is this "--color" option coming from? Is this a nodejs thing? Its not a pm2 option, is it?

Nope it's a chalk thing: see supports-color, a dependency of Chalk, where the dependency has-flag checks whether process.argv has --no-color.

This didn't work for me:

$ pm2 start myapp.js -- --color

This supportsColor worked:

$ FORCE_COLOR=1 pm2 start myapp.js
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ldarren picture ldarren  路  3Comments

jubairsaidi picture jubairsaidi  路  3Comments

xzycn picture xzycn  路  3Comments

alexpts picture alexpts  路  3Comments

mario-mui picture mario-mui  路  3Comments