Registry / serialization / cli-table3

cli-table3

JSON →
library0.6.5jsnpmunverified

cli-table3 is an active utility library for Node.js environments, providing a robust mechanism to render highly customizable unicode-aided tables directly in the command line. As of version 0.6.5, it offers features such as cell spanning (both column and row), individual cell styling (borders, padding), flexible text alignment, word wrapping with configurable boundaries, and enhanced handling of ANSI color characters within cell content. It is the maintained successor and API-compatible evolution of the unmaintained `cli-table` and `cli-table2` packages. Releases are consistent, addressing bug fixes and introducing enhancements like hyperlink support, `bigint` cell content, and improved TypeScript types. It ships with comprehensive TypeScript type definitions, making it suitable for modern JavaScript and TypeScript projects.

npm install cli-table3
INSTALL
IMPORT
SIG · CLI-TABLE3
C
cli-table3
serializationjavascriptv0.6.5
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
✓ import Table from 'cli-table3';
✗ import { Table } from 'cli-table3';
The primary `Table` class is exported as a default export in ESM. CommonJS uses `require('cli-table3')` directly.
Table.TableOptions
✓ import Table, { TableOptions } from 'cli-table3';
✗ import { Table, TableOptions } from 'cli-table3';
Type definitions like `TableOptions` are available as named exports. Ensure you still use the default import for the `Table` class.
CellOptions
✓ import type { CellOptions } from 'cli-table3';
✗ import { CellOptions } from 'cli-table3';
Import types using `import type` for clarity and to avoid bundling issues in some build setups.

Demonstrates creating a horizontal table with headers, custom column widths, and cell styling, including a column span. It also shows a basic vertical table setup.

import Table, { TableOptions, CellOptions } from 'cli-table3'; interface MyRow { header1: string | CellOptions; header2: string | CellOptions; } const tableConfig: TableOptions = { head: ['Project', 'Status', 'Progress'], colWidths: [30, 15, 20], wordWrap: true, style: { 'header': ['cyan', 'bold'], 'border': ['grey'], 'compact': true } }; const table = new Table(tableConfig); // Add rows table.push( ['CLI Table 3', { content: 'Active', style: { fg: 'green' } }, '100%'], ['Feature A', 'In Development', { content: '60%', style: { fg: 'yellow' } }], ['Feature B', { content: 'On Hold', style: { fg: 'red' } }, '10%'], [{ content: 'Total tasks: 3', colSpan: 3, hAlign: 'center' }] ); console.log(table.toString()); // Example of a vertical table const verticalTable = new Table(); verticalTable.push( { 'Name': 'Alice' }, { 'Age': '30' }, { 'City': 'New York' } ); console.log('\n--- Vertical Table ---\n'); console.log(verticalTable.toString());
Debug
Known issues
breakingNode.js version requirements were updated in v0.5.0. Projects using older Node.js runtimes (prior to 10.* or 12.*) will encounter errors.
fix
Ensure your Node.js environment is version 10.* or >= 12.*. Update your `engines` field in `package.json` accordingly if deploying.
affects: >=0.5.0
gotchacli-table3 is the maintained successor to the unmaintained `cli-table` and `cli-table2` packages. While API compatible, always install `cli-table3` to receive ongoing updates and bug fixes.
fix
Always use `npm install cli-table3` or `yarn add cli-table3`. Avoid the older, unmaintained packages to prevent security vulnerabilities and unpatched bugs.
affects: >=0.4.0
breakingThe initial release of `cli-table3` (v0.4.0) introduced breaking changes compared to `cli-table2` (e.g., removal of 'lodash' dependency, internal refactors). While API compatible at a high level, direct migration from `cli-table2` might require minor adjustments if relying on specific internals or removed dependencies.
fix
Review the changelog for v0.4.0 and higher when migrating from `cli-table2`. Test your application thoroughly after upgrading.
affects: >=0.4.0
Errors
Common errors & fixes
TypeError: Table is not a constructor
Attempting to use named import syntax (`import { Table } from 'cli-table3';`) for the main `Table` class, which is a default export.
fix
Use the correct default import syntax: `import Table from 'cli-table3';`.
Error: cli-table3 requires Node.js version 10.* || >= 12.*
Running `cli-table3` on an unsupported Node.js version, specifically older than 10.x or between 10.x and 12.x.
fix
Upgrade your Node.js runtime to version 10.* or >= 12.*. You can use tools like `nvm` (Node Version Manager) to manage multiple Node.js versions.
Property 'href' does not exist on type 'CellOptions'
Attempting to use the `href` property within `CellOptions` (for hyperlink support) with an older version of `cli-table3` or outdated TypeScript type definitions.
fix
Ensure you are using `cli-table3` version 0.6.2 or higher, as `href` support was added in this version. Update your package and regenerate `node_modules/@types` if necessary.
Upgrade
Version history
0.6.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
cli-table3 — npm install cli-table3 · libregistry