Kolorist is a minimal utility library for Node.js environments, designed to apply ANSI escape codes to strings for colored console output. The current stable version, 1.8.0, includes support for 24-bit TrueColor detection, which automatically falls back to Ansi 256 for terminals that lack full TrueColor support, such as the built-in macOS Terminal.app. The library maintains an active release cadence, focusing on minor enhancements and bug fixes like improved handling of `NO_COLOR` and `FORCE_COLOR` environment variables and better module resolution compatibility. Its key differentiators include a tiny footprint, direct focus on standard I/O coloring without unnecessary abstractions, and robust detection of terminal capabilities to ensure appropriate color rendering or disablement. Kolorist ships with TypeScript types, making it well-suited for modern JavaScript and TypeScript projects.
npm install koloristVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic usage of color functions, programmatic color toggling, and stripping ANSI colors from a string.
Be aware of the `NO_COLOR` and `FORCE_COLOR` environment variables in CI/production environments. Use `FORCE_COLOR=0` to explicitly disable colors or `FORCE_COLOR=1` to enable them if `TERM=dumb` is set.
Upgrade to Kolorist `1.3.2` or higher to ensure compatibility with Node.js 12+, or ensure your project's build process handles appropriate down-transpilation.
Test your application's output in various terminal emulators to understand how colors are rendered. If precise TrueColor is critical, verify terminal capabilities or specify Ansi 256 colors directly.
Ensure you are using a modern Node.js version (12.20.0+, 14.13.0+, or 16.0.0+ for full `exports` field support) and up-to-date bundlers (e.g., Webpack 5, Rollup 3, esbuild) that correctly resolve the `exports` field in `package.json`.
Refactor your imports to use ESM `import` statements (e.g., `import { red } from 'kolorist'`). Ensure your `package.json` specifies `"type": "module"` if using ESM, or configure your bundler to handle ESM dependencies appropriately.Verify that you are using correct ESM named import syntax: `import { red } from 'kolorist';`. Do not attempt to `require` named exports directly from an ESM-first package.Upgrade to Kolorist `1.3.1` or newer, which includes a fix for this issue. If upgrading is not immediately possible, ensure `process.env.TERM` is always defined in your execution environment (e.g., `TERM=xterm node my-script.js`).
No dependency data recorded yet.