directory

Hello everyone, here I come!


Before because of

Some days ago when I was developing the VUE project, I found that the console would have colorful fonts every time I ran the project


At that time, I must have noticed that recently when I was learning Express, I used breakpoints and console.log to check the state for better debugging code, and I found that the information printed in the terminal was unidentifiable. At that time, I realized how important it is to output highly identifiable information in the terminal.

Through a search, found through the following code to achieve


Finally, we learned the usage of Chalk through NPM.

Chalk is introduced


Chalk is an NPM package that can modify terminal output character styles.

The installation

npm install chalk -S
Copy the code

use

const chalk = require('chalk')

console.log(chalk.blue('Hello world! '))
Copy the code

Or you can define your own theme:

const chalk = require('chalk')
let log = {
  error(str) {
    chalk.bold.red(str)
  }
 // your own themes  } Copy the code

conclusion

With Chalk, you no longer have to worry about the messiness of the terminal output.