chalk/chalk

Color not represented inside macOS terminal

jpstijn opened this issue · 2 comments

When building my own CLI Tool i sometimes find the color not correctly displayed:

When printing the following:

const yellow = chalk.hex("#FFD833");

console.log(yellow(`(v${version})\n`));

Expected:
image

Received:
Screenshot 2022-09-12 at 08 51 54

Does anyone know what is going wrong? (I know i have not provided much detail)

Qix- commented

The MacOS terminal doesn't support Truecolor (16-million RGB support, which is what .hex() requires). You need to use an Ansi256 color with .ansi256(code) instead, or install color-convert and do const yellow = chalk.ansi256(colorConvert.hex.ansi256('#FFD833')) (this used to be built-in functionality but we removed it due to it being bulky and atypical usage).

Hope that helps!

Sorry my mistake! Thanks for your reply.