问题描述
我不得不改变控制台背景颜色为白色,因为眼睛的问题,但字体是灰色的,它使消息不可读。
Node.js中更改控制台字体颜色的几个模块最受欢迎的是:
- 粉笔 -
- 颜色 -
- Cli-color -
用法:
var chalk = require ('粉笔');
console.log(chalk.red('Text in red'));
用法:
var colors = require('colors / safe'); //不改变字符串原型
console.log(colors.red('This String will Display RED'));
有几种颜色可供选择,以及文字格式,例如粗体 >修改 字符串原型,如果您更愿意使用原型,则需要使用或
用法:
var clc = require('cli-color');
console.log(clc.red('Text in red')); cli-color 和需要更多打字但你得到类似的结果(到颜色),没有String原型添加。两者都支持各种颜色,格式(粗体/斜体等)和单元测试。
选择您的选择。
I had to change the console background color to white because of eye problems, but the font is gray colored and it makes the messages unreadable. How can I change it?
解决方案 There are a few modules for changing console font color in Node.js the most popular are:
- Chalk - https://github.com/sindresorhus/chalk
- Colors - https://www.npmjs.org/package/colors
- Cli-color - https://www.npmjs.org/package/cli-color
chalk usage:
var chalk = require('chalk');
console.log(chalk.red('Text in red'));
colors usage:
var colors = require('colors/safe'); // does not alter string prototype
console.log(colors.red('This String Will Display RED'));
There are a few colors to chose from as well as text formatting like Bold and Italic.
Many people have noted their disapproval at Colors altering the String prototype, if you prefer your prototypes left alone, you will want to use cli-color or chalk
cli-color usage:
var clc = require('cli-color');
console.log(clc.red('Text in red'));
Both cli-color and chalk require a bit more typing but you get similar results (to colors) without String prototype additions. Both support a good range of colors, formatting (bold/italics etc.) and have unit tests.
Take your pick.
这篇关于如何改变node.js的控制台字体颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!