DEV Community

Serge van den Oever
Serge van den Oever

Posted on • Originally published at sergevandenoever.nl

1

Chalk, TypeScript and Lerna

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"));
Enter fullscreen mode Exit fullscreen mode

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"
   ...
Enter fullscreen mode Exit fullscreen mode

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more