Registry / serialization / cli-simple-table

cli-simple-table

JSON →
library1.1.1jsnpmunverified

cli-simple-table is a lightweight utility for generating basic, unstyled ASCII tables in command-line interfaces. Its design prioritizes simplicity and a minimal API, making it suitable for quick console output without extensive configuration. The library allows users to define table headers, add rows, and configure column-specific options such as text alignment and maximum width for truncation. It provides a `toString()` method to render the table for printing. The current stable version is `1.1.1`, released in late 2021, indicating a moderate release cadence. It differentiates itself from more feature-rich table rendering libraries by offering a focused solution for common CLI display needs. The package ships with TypeScript types, ensuring good developer experience for TypeScript projects, and supports both CommonJS and ES Module environments.

npm install cli-simple-table
INSTALL
IMPORT
SIG · CLI-SIMPLE-TABLE
C
cli-simple-table
serializationjavascriptv1.1.1
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.

SimpleTable
const SimpleTable = require('cli-simple-table');
const { SimpleTable } = require('cli-simple-table');
This is the primary way to import the library in CommonJS environments, especially after `v1.1.1` solidified the `export =` pattern for CJS.
SimpleTable
import SimpleTable from 'cli-simple-table';
import { SimpleTable } from 'cli-simple-table';
Recommended for modern JavaScript projects using ES Modules (ESM), available since `v1.1.0` when an ESM entry point was introduced.
SimpleTable
import SimpleTable = require('cli-simple-table');
This TypeScript-specific import syntax is for consuming CommonJS modules with `export =` in environments where `esModuleInterop` might not be enabled or preferred.

Demonstrates basic table creation with headers and rows, including colored text using an external library like `chalk`.

import SimpleTable from 'cli-simple-table'; import chalk from 'chalk'; // chalk is an external dependency const table = new SimpleTable(); table.header('Name', 'Emoji'); table.row(chalk.red('Squid'), '🦑'); table.row(chalk.green('Frog'), '🐸'); table.row(chalk.yellow('Tiger'), '🐯'); table.row(chalk.blue('Whale'), '🐳'); table.row(chalk.magenta('Unicorn'), '🦄'); table.row(chalk.cyan('Dolphin'), '🐬'); table.row(chalk.white('Panda'), '🐼'); console.log(table.toString());
Debug
Known issues
breakingVersion `1.1.0` introduced an ES Module (ESM) entry point. While CommonJS support was maintained, projects relying solely on `require()` might need to ensure correct import paths or adjust bundler configurations if they previously relied on specific internal module resolution patterns.
fix
For ESM, use `import SimpleTable from 'cli-simple-table';`. For CommonJS, continue using `const SimpleTable = require('cli-simple-table');`. Ensure your `tsconfig.json` (if applicable) is configured for correct module resolution (`"moduleResolution": "node"` or `"bundler"`).
affects: >=1.1.0
gotchaUsing an incorrect import style (e.g., named import when a default is expected, or vice-versa) can lead to runtime errors like 'is not a constructor' or 'undefined'. The library primarily exports a default `SimpleTable` class.
fix
Always import `SimpleTable` as a default export for ESM (`import SimpleTable from 'cli-simple-table';`) and as the main module export for CommonJS (`const SimpleTable = require('cli-simple-table');`).
affects: >=1.0.0
gotchaPrior to `v1.1.1`, there were edge cases in TypeScript strict mode that could lead to type-related issues. While fixed, older versions might exhibit unexpected behavior in highly strict TypeScript environments.
fix
Upgrade to `cli-simple-table@1.1.1` or later to ensure full compatibility and correctness in TypeScript strict mode.
affects: <1.1.1
Errors
Common errors & fixes
TypeError: cli_simple_table is not a constructor
Attempting to instantiate `cli-simple-table` with an incorrect import (e.g., `new cli_simple_table.SimpleTable()` or `new (require('cli-simple-table')).default()`) when the module itself is the constructor.
fix
Ensure you are importing and instantiating the module directly: `const SimpleTable = require('cli-simple-table'); new SimpleTable();` or `import SimpleTable from 'cli-simple-table'; new SimpleTable();`.
ERR_REQUIRE_ESM
Trying to `require()` the `cli-simple-table` package in an environment where it's being resolved as an ES Module, and the CommonJS `main` entry point is not correctly picked up or is being overridden.
fix
Verify your `package.json`'s `type` field, module resolution settings in bundlers, and ensure the correct entry point (`main` for CJS, `module` for ESM) is being used. If you are in an ESM project, prefer `import SimpleTable from 'cli-simple-table';`.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
cli-simple-table — npm install cli-simple-table · libregistry