{"id":16969,"library":"cli-table2","title":"CLI Table 2","description":"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.","status":"abandoned","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/jamestalmage/cli-table2","tags":["javascript","node","command","line","cli","table","tables","tabular","unicode"],"install":[{"cmd":"npm install cli-table2","lang":"bash","label":"npm"},{"cmd":"yarn add cli-table2","lang":"bash","label":"yarn"},{"cmd":"pnpm add cli-table2","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import Table from 'cli-table2';","symbol":"Table","correct":"const Table = require('cli-table2');"},{"note":"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`.","wrong":"const { Table } = require('cli-table2');","symbol":"Table (destructuring)","correct":"const Table = require('cli-table2');"},{"note":"Table configuration options (e.g., `head`, `chars`, `colWidths`) are properties of the options object passed to the `Table` constructor, not separate module exports.","wrong":"import { head, chars } from 'cli-table2';","symbol":"Configuration Options","correct":"const table = new Table({ head: ['Header'], chars: { /* ... */ } });"}],"quickstart":{"code":"const Table = require('cli-table2');\n\n// --- Horizontal Table ---\nconst horizontalTable = new Table({\n    head: ['TH 1 label', 'TH 2 label', 'TH 3 Label'],\n    colWidths: [20, 30, 15] // Example widths\n});\n\nhorizontalTable.push(\n    ['First value A', 'Second value B', 'Third value C'],\n    ['More data 1', 'More data 2', 'More data 3']\n);\nconsole.log('--- Horizontal Table ---');\nconsole.log(horizontalTable.toString());\nconsole.log('\\n'); // Add a newline for separation\n\n// --- Vertical Table ---\nconst verticalTable = new Table();\nverticalTable.push(\n    { 'Some key': 'Some value' },\n    { 'Another key': 'Another value with a longer string to demonstrate wrapping' }\n);\nconsole.log('--- Vertical Table ---');\nconsole.log(verticalTable.toString());\nconsole.log('\\n');\n\n// --- Cross Table ---\nconst crossTable = new Table({ head: [\"\", \"Top Header 1\", \"Top Header 2\"] });\ncrossTable.push(\n    { 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] },\n    { 'Left Header 2 with a long name': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] }\n);\nconsole.log('--- Cross Table ---');\nconsole.log(crossTable.toString());\nconsole.log('\\n');\n\n// --- Custom Styles Example ---\nconst customTable = new Table({\n  head: ['Styled Header 1', 'Styled Header 2'],\n  chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗'\n         , 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝'\n         , 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼'\n         , 'right': '║' , 'right-mid': '╢' , 'middle': '│' },\n  style: { 'header': [], 'border': ['cyan'], 'compact': false } // Example style\n});\ncustomTable.push(\n    ['Custom Data 1', 'Custom Data 2']\n);\nconsole.log('--- Custom Styled Table ---');\nconsole.log(customTable.toString());","lang":"javascript","description":"Demonstrates the creation of horizontal, vertical, and cross-tabulated CLI tables, including basic data insertion, column width specification, and custom character styling."},"warnings":[{"fix":"Consider migrating to actively maintained alternatives for critical applications or fork and maintain the package yourself if absolutely necessary.","message":"This 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.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use CommonJS `require()` syntax: `const Table = require('cli-table2');` Ensure your project configuration or build tools are set up to handle CommonJS modules.","message":"This 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.","severity":"gotcha","affected_versions":">=0.2.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Change your import statement to `const Table = require('cli-table2');` and ensure your environment is configured to properly handle CommonJS modules.","cause":"Attempting to use ES Modules import syntax (`import Table from 'cli-table2';`) with a CommonJS package in a TypeScript or modern JavaScript environment.","error":"TypeError: cli_table2_1.Table is not a constructor"},{"fix":"Access the exported constructor directly without destructuring: `const Table = require('cli-table2');`.","cause":"Using destructuring assignment (`const { Table } = require('cli-table2');`) for a CommonJS module that exports a single constructor directly as `module.exports`.","error":"TypeError: Table is not a constructor (when using destructuring)"},{"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.","cause":"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.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm","meta_description":null}