Registry / serialization / cli-table2

cli-table2

JSON →
library0.2.0jsnpmunverified

cli-table2 is a Node.js utility designed for rendering highly customizable, unicode-aided tables directly within command-line interfaces. Released as version 0.2.0, it presents itself as an API-compatible, drop-in replacement for the original `cli-table` package, offering enhanced features such as column and row spanning, per-cell styling (including borders and padding), vertical text alignment, and automatic word wrapping. The package also provides more robust handling of ANSI color characters within cell text, ensuring correct rendering across multiple lines. Due to its very low version number and apparent lack of recent updates since its initial releases, it appears to be an unmaintained package, which may pose compatibility challenges with newer Node.js versions or introduce unpatched security vulnerabilities. It primarily targets CommonJS environments and has no stated release cadence, reflecting its abandoned status.

npm install cli-table2
INSTALL
IMPORT
SIG · CLI-TABLE2
C
cli-table2
serializationjavascriptv0.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

Table
✓ const Table = require('cli-table2');
✗ import Table from 'cli-table2';
cli-table2 is a CommonJS module and exports the Table constructor directly as its `module.exports`. ESM 'import' syntax is not supported in this version.
Table (destructuring)
✓ const Table = require('cli-table2');
✗ const { Table } = require('cli-table2');
The package exports the Table constructor directly, not an object containing a 'Table' property. Using destructuring assignment like `{ Table }` will result in 'Table' being `undefined`.
Configuration Options
✓ const table = new Table({ head: ['Header'], chars: { /* ... */ } });
✗ import { head, chars } from 'cli-table2';
Table configuration options (e.g., `head`, `chars`, `colWidths`) are properties of the options object passed to the `Table` constructor, not separate module exports.

Demonstrates the creation of horizontal, vertical, and cross-tabulated CLI tables, including basic data insertion, column width specification, and custom character styling.

const Table = require('cli-table2'); // --- Horizontal Table --- const horizontalTable = new Table({ head: ['TH 1 label', 'TH 2 label', 'TH 3 Label'], colWidths: [20, 30, 15] // Example widths }); horizontalTable.push( ['First value A', 'Second value B', 'Third value C'], ['More data 1', 'More data 2', 'More data 3'] ); console.log('--- Horizontal Table ---'); console.log(horizontalTable.toString()); console.log('\n'); // Add a newline for separation // --- Vertical Table --- const verticalTable = new Table(); verticalTable.push( { 'Some key': 'Some value' }, { 'Another key': 'Another value with a longer string to demonstrate wrapping' } ); console.log('--- Vertical Table ---'); console.log(verticalTable.toString()); console.log('\n'); // --- Cross Table --- const crossTable = new Table({ head: ["", "Top Header 1", "Top Header 2"] }); crossTable.push( { 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] }, { 'Left Header 2 with a long name': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] } ); console.log('--- Cross Table ---'); console.log(crossTable.toString()); console.log('\n'); // --- Custom Styles Example --- const customTable = new Table({ head: ['Styled Header 1', 'Styled Header 2'], chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗' , 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝' , 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼' , 'right': '║' , 'right-mid': '╢' , 'middle': '│' }, style: { 'header': [], 'border': ['cyan'], 'compact': false } // Example style }); customTable.push( ['Custom Data 1', 'Custom Data 2'] ); console.log('--- Custom Styled Table ---'); console.log(customTable.toString());
Debug
Known issues
breakingThis package is effectively abandoned and unmaintained since its 0.2.0 release in 2016. Users may encounter compatibility issues with newer Node.js versions or unpatched security vulnerabilities due to a lack of ongoing development and bug fixes.
fix
Consider migrating to actively maintained alternatives for critical applications or fork and maintain the package yourself if absolutely necessary.
affects: >=0.2.0
gotchaThis package is a CommonJS module and does not natively support ES Modules (`import`). Attempting to `import` it will result in runtime errors in an ESM environment.
fix
Use CommonJS `require()` syntax: `const Table = require('cli-table2');` Ensure your project configuration or build tools are set up to handle CommonJS modules.
affects: >=0.2.0
gotchaThe package's documentation explicitly mentions styling through `colors.js`. The `colors.js` library experienced a severe supply chain attack in January 2022, leading to potential breaking changes and the introduction of malicious code in certain versions. While `cli-table2` predates this incident, relying on `colors.js` for styling in projects that also use `cli-table2` could expose applications to risks.
fix
Carefully review your project's dependency tree to ensure no malicious versions of `colors.js` are installed. If `colors.js` is used, consider removing it or switching to safer, actively maintained alternatives like `chalk` or `colorette` for CLI coloring.
affects: *
Errors
Common errors & fixes
TypeError: cli_table2_1.Table is not a constructor
Attempting to use ES Modules import syntax (`import Table from 'cli-table2';`) with a CommonJS package in a TypeScript or modern JavaScript environment.
fix
Change your import statement to `const Table = require('cli-table2');` and ensure your environment is configured to properly handle CommonJS modules.
TypeError: Table is not a constructor (when using destructuring)
Using destructuring assignment (`const { Table } = require('cli-table2');`) for a CommonJS module that exports a single constructor directly as `module.exports`.
fix
Access the exported constructor directly without destructuring: `const Table = require('cli-table2');`.
ReferenceError: require is not defined
Attempting to use CommonJS `require` in an ES Module context (e.g., in a file where `type: module` is set in `package.json` or a `.mjs` file) without proper transpilation or configuration.
fix
If your project uses ES Modules, consider rewriting your application to use an alternative library that supports ESM, or configure your build system (e.g., Webpack, Rollup) to transpile CommonJS modules for browser/ESM compatibility.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
cli-table2 — npm install cli-table2 · libregistry