Registry / http-networking / cli-high

cli-high

JSON →
library0.4.3jsnpmunverified

cli-high is a lightweight, MIT-licensed JavaScript library providing syntax highlighting specifically designed for terminal output. It is currently at version 0.4.3 and appears to be in active development, having been introduced around 2024. As a "tiny" utility, it prioritizes minimal dependencies and a focused scope, primarily offering a single `highlight` function for programmatic use. The library ships with TypeScript types, enabling a robust development experience in TypeScript projects. While its release cadence isn't explicitly defined, as a 0.x.x version, users should anticipate potential API changes in minor or even patch releases. Its primary differentiators are its small footprint and dedicated purpose for aesthetic CLI output, rather than complex, browser-based highlighting solutions.

npm install cli-high
INSTALL
IMPORT
SIG · CLI-HIGH
C
cli-high
http-networkingjavascriptv0.4.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

highlight
import { highlight } from 'cli-high'
const highlight = require('cli-high')
This is the primary named export for programmatic highlighting. While CommonJS might be supported, the library's examples and TypeScript types promote an ESM-first approach. Directly requiring the package might not yield the function.
Options
import type { Options } from 'cli-high'
Use `import type` for importing the configuration options interface, which allows specifying language, theme, and other highlighting parameters. This ensures type-only imports for better tree-shaking and explicit type usage.
Language
import type { Language } from 'cli-high'
The `Language` type is a string literal union defining the supported language identifiers for the highlighter, useful for type-safe language specification with the `highlight` function's options.

Demonstrates programmatic use of `cli-high` to syntax-highlight JavaScript and JSON code for terminal output, including specifying language and theme options.

import { highlight, type Options } from 'cli-high'; const javascriptCode = ` function greet(name: string) { console.log("Hello, " + name + "!"); } greet("World"); `; const options: Options = { language: 'js', // Or 'typescript', 'json', etc. theme: 'dark' // Or 'light' }; const highlightedCode = highlight(javascriptCode, options); console.log(highlightedCode); // Example of highlighting a different language const jsonConfig = `{ "name": "cli-high-project", "version": "1.0.0", "scripts": { "start": "node index.js" } }`; const highlightedJson = highlight(jsonConfig, { language: 'json' }); console.log('\n' + highlightedJson);
Debug
Known issues
breakingAs a 0.x.x version, cli-high's API is subject to breaking changes in minor or even patch releases without strict adherence to SemVer. The API surface may evolve rapidly.
fix
Always refer to the official GitHub repository and any provided changelog or release notes before upgrading to ensure compatibility with your codebase. Pinning exact versions is recommended for production.
affects: >=0.0.0
gotchaMixing CommonJS `require()` with cli-high's presumed ESM-first approach (indicated by TypeScript usage and import examples) can lead to import errors like 'TypeError: highlight is not a function'.
fix
Ensure your project is configured for ES Modules (e.g., `'type': 'module'` in `package.json` or `.mjs` file extension). If you must use CommonJS, consider dynamic `import()` or verify the package's CJS export compatibility.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: (0, cli_high__WEBPACK_IMPORTED_MODULE_0__.highlight) is not a function
This error typically occurs in bundled environments (like Webpack) when a named export is incorrectly treated as a default export, or when the `highlight` function is not correctly tree-shaken/imported.
fix
Verify that you are using a named import: `import { highlight } from 'cli-high'`. Check your bundler's configuration for ESM compatibility and ensure no conflicting default imports or incorrect aliasing.
SyntaxError: Cannot use import statement outside a module
Attempting to use ES module `import` syntax in a Node.js environment configured for CommonJS (`require()`) without proper module configuration.
fix
To use ESM, add `'type': 'module'` to your `package.json` file, or save your script files with a `.mjs` extension. Alternatively, if you need to load ESM in a CJS context, use dynamic import: `const { highlight } = await import('cli-high');`.
Error: ENOENT: no such file or directory, open './path/to/your/js/file'
When using `cli-high` via its CLI (`npx cli-high ./path/to/file`), this error indicates that the provided file path does not exist or is incorrect relative to where the command is executed.
fix
Double-check the file path provided to the `npx cli-high` command. Ensure the file exists and the path is either absolute or correct relative to your current working directory.
Upgrade
Version history
0.4.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources