I'm trying to log to the console in different colors using chalk
but I haven't gotten it to work. I have a file that consists of the following two lines and I'm running it with the command node test.js
var chalk = require('chalk');
console.log(chalk.red('Hello'));
// outputs 'hello' in black
The following command does output in red so I know that it's possible in my terminal.
node <<< "console.log('\x1b[31mhello\x1b[m')"
I have "chalk": "^2.1.0"
in my dev dependencies and have run a npm install
. The following shows some of my setup.
$ node --version
v8.2.1
$ echo $TERM
xterm-256color
$ echo $SHELL
/bin/bash
$ echo $TERM_PROGRAM
Apple_Terminal
Any ideas?
Additionally:
It looks like chalk
isn't outputting the ansi codes at all for some reason...
console.log(util.inspect('hello'));
//'hello'
console.log(util.inspect(chalk.red('hello')));
// 'hello'
console.log(util.inspect('\x1b[31mhello\x1b[m'));
// '\u001b[31mhello\u001b[m'