Serge van den Oever's weblog

Chalk, TypeScript and Lerna

February 15, 2022 • ☕️ 1 min read

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("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 TwitterEdit on GitHub

Serge van den Oever's weblog

Serge van den Oever

Personal blog by Serge van den Oever - als je maar lol hebt...
Twitter: @svdoever
LinkedIn: Serge van den Oever - articles on LinkedIn

Technology Consultant @ Macaw
Competence Team Lead Custom Application Development @ Macaw
2022 Technology Sitecore Most Valuable Professional
2021 Technology Sitecore Most Valuable Professional