Tue Feb 15 2022 • ☕️ 1 min read • you like my writing? Buy me a coffee
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"
...
Discuss on Twitter • Edit on GitHub
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. You are free to share and adapt this work for non-commercial purposes, provided you give appropriate credit, provide a link to the license, and indicate if changes were made. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
Personal blog by Serge van den Oever - als je maar lol hebt...
X: @svdoever
LinkedIn: Serge van den Oever - articles on LinkedIn
GitHub: svdoever
Technology Consultant @ Macaw
2021-2024 Sitecore Technology MVP