{"id":16965,"library":"cli-simple-table","title":"CLI Simple Table","description":"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.","status":"active","version":"1.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/privatenumber/cli-simple-table","tags":["javascript","cli","table","simple","minimal","typescript"],"install":[{"cmd":"npm install cli-simple-table","lang":"bash","label":"npm"},{"cmd":"yarn add cli-simple-table","lang":"bash","label":"yarn"},{"cmd":"pnpm add cli-simple-table","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is the primary way to import the library in CommonJS environments, especially after `v1.1.1` solidified the `export =` pattern for CJS.","wrong":"const { SimpleTable } = require('cli-simple-table');","symbol":"SimpleTable","correct":"const SimpleTable = require('cli-simple-table');"},{"note":"Recommended for modern JavaScript projects using ES Modules (ESM), available since `v1.1.0` when an ESM entry point was introduced.","wrong":"import { SimpleTable } from 'cli-simple-table';","symbol":"SimpleTable","correct":"import SimpleTable from 'cli-simple-table';"},{"note":"This TypeScript-specific import syntax is for consuming CommonJS modules with `export =` in environments where `esModuleInterop` might not be enabled or preferred.","symbol":"SimpleTable","correct":"import SimpleTable = require('cli-simple-table');"}],"quickstart":{"code":"import SimpleTable from 'cli-simple-table';\nimport chalk from 'chalk'; // chalk is an external dependency\n\nconst table = new SimpleTable();\n\ntable.header('Name', 'Emoji');\n\ntable.row(chalk.red('Squid'), '🦑');\ntable.row(chalk.green('Frog'), '🐸');\ntable.row(chalk.yellow('Tiger'), '🐯');\ntable.row(chalk.blue('Whale'), '🐳');\ntable.row(chalk.magenta('Unicorn'), '🦄');\ntable.row(chalk.cyan('Dolphin'), '🐬');\ntable.row(chalk.white('Panda'), '🐼');\n\nconsole.log(table.toString());","lang":"typescript","description":"Demonstrates basic table creation with headers and rows, including colored text using an external library like `chalk`."},"warnings":[{"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\"`).","message":"Version `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.","severity":"breaking","affected_versions":">=1.1.0"},{"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');`).","message":"Using 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to `cli-simple-table@1.1.1` or later to ensure full compatibility and correctness in TypeScript strict mode.","message":"Prior 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.","severity":"gotcha","affected_versions":"<1.1.1"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"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();`.","cause":"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.","error":"TypeError: cli_simple_table is not a constructor"},{"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';`.","cause":"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.","error":"ERR_REQUIRE_ESM"}],"ecosystem":"npm","meta_description":null}