Chalk to Node.js util styleText

R

richiemccoll

Migrate from Chalk to Node.js util styleText

chalk-to-util-styletext

This codemod aims to help you reduce external dependencies by transforming chalk method calls to use the native Node.js styling functionality. It will also handle automatic removal of the chalk package from the package.json.

Compatible Features:

  • Basic colors (red, green, blue, yellow, etc.)
  • Bright colors (redBright, greenBright, etc.)
  • Background colors (bgRed, bgGreen, etc.)
  • Text modifiers (bold, dim, italic, underline, strikethrough, etc.)
  • Style chaining via array syntax
  • Environment variable support (NO_COLOR, NODE_DISABLE_COLORS, FORCE_COLOR)

Non-Compatible Features:

  • Custom RGB colors (chalk.rgb(), chalk.hex())
  • 256-color palette (chalk.ansi256())
  • Template literal syntax (chalk...``)
  • Advanced modifiers with limited terminal support (overline, blink, etc.)

The source code for this codemod can be found in the chalk-to-util-styletext directory.

You can find this codemod in the Codemod Registry.

npx codemod @nodejs/chalk-to-util-styletext

Example:

import  from 'chalk';

.(.red('Error message'));

.(.red.bold('Important error'));

const  = .red;
.(('Error'));

const  = .blue.bold;
.(('Info'));
마지막 업데이트
2025년 12월 19일
읽는 데 걸리는 시간
1분
기여하기
이 페이지 수정
목차
  1. chalk-to-util-styletext
  2. Compatible Features:
  3. Non-Compatible Features:
  4. Example: