After a lot of struggling with getting chalk to work with TypeScript I finally found (in the documentation) that you should just use version 4 of chalk! In the release notes it is stated that:
If you use TypeScript, you will want to stay on Chalk 4 until TypeScript 4.6 is out.
I can now use chalk as follows from TypeScript:
import chalk from "chalk";
console.log(chalk.red("This is red"));
Next problem: color output is stripped when using Lerna.
If you run lerna run doit --scope mypackage --stream
all color output is stripped.
To fix this set the environment variable FORCE_COLOR=1
.
For example in an npm script do the following:
...
"run_doit_in_package_mypackage": "cross-env FORCE_COLOR=1 lerna run doit --scope mypackage --stream"
...
Top comments (0)