admin管理员组文章数量:1296440
I've had no luck in seeing any results appear in my iTerm2 while trying to use chalk which is a terminal string styling package. I followed all the steps in installing the package but I'm not seeing any colored string result appear when I run a basic console.log("hello");
in my chalk.js
file.
Here is what I am doing.
#!/usr/bin/env node
var chalk = require('chalk');
chalk.blue('Hello world!');
console.log("hello");
Then in iTerm2 I run node chalk.js
and I see no colored strings just plane old boring grey..
Anyone know what I'm doing wrong here?
I've had no luck in seeing any results appear in my iTerm2 while trying to use chalk which is a terminal string styling package. I followed all the steps in installing the package but I'm not seeing any colored string result appear when I run a basic console.log("hello");
in my chalk.js
file.
Here is what I am doing.
#!/usr/bin/env node
var chalk = require('chalk');
chalk.blue('Hello world!');
console.log("hello");
Then in iTerm2 I run node chalk.js
and I see no colored strings just plane old boring grey..
Anyone know what I'm doing wrong here?
https://www.npmjs./package/chalk
Share edited Jul 31, 2015 at 20:04 Qix - MONICA WAS MISTREATED 15.1k17 gold badges92 silver badges155 bronze badges asked Mar 31, 2015 at 8:46 brent_whitebrent_white 1,0191 gold badge14 silver badges27 bronze badges 3-
It should "just" work, since Iterm2 sets
TERM
toxterm
by default, and that is what chalk checks for - see source github./sindresorhus/supports-color/blob/master/index.js – Thomas Dickey Commented Mar 31, 2015 at 10:22 - @ThomasDickey thax for your imput. Can you tell me exactly how you get it run "your set up" for chalk? – brent_white Commented Apr 2, 2015 at 4:07
- I was reading the source code to help explain it -- can setup to explore that a little... – Thomas Dickey Commented Apr 2, 2015 at 8:11
1 Answer
Reset to default 10Chalk functions return a string with the appropriate ANSI escape codes.
You need to console log the result of chalk calls.
console.log(chalk.blue("Hello, world!"));
If you still don't see any color, try running with the mand line argument --colors
. If that still doesn't work, set an environment variable FORCE_COLOR=1
.
If it still doesn't work, you're wele to file a bug report!
本文标签: javascriptHow to use Chalk Terminal string styling done rightStack Overflow
版权声明:本文标题:javascript - How to use Chalk Terminal string styling done right - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741629052a2389251.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论