{"id":16791,"library":"cli-tableau","title":"CLI Tableau","description":"cli-tableau is a robust JavaScript library designed for rendering pretty, highly customizable tables in command-line interfaces using Unicode characters. It offers extensive control over table structure, including options for horizontal, vertical, and cross-table layouts, and allows for detailed customization of borders, column widths, and styling characters. The current stable version, 2.0.1, indicates a mature codebase. Its release cadence appears to be relatively slow, focusing on stability. A key differentiator is its granular control over the `chars` property, enabling developers to define every single line and intersection character, from full Unicode borders to completely invisible separators, offering unparalleled flexibility in visual output compared to simpler table rendering utilities. It is primarily used within Node.js environments for CLI tools.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/Keymetrics/cli-table","tags":["javascript","cli","colors","table"],"install":[{"cmd":"npm install cli-tableau","lang":"bash","label":"npm"},{"cmd":"yarn add cli-tableau","lang":"bash","label":"yarn"},{"cmd":"pnpm add cli-tableau","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"cli-tableau is primarily a CommonJS module. Direct ES module imports may not work without a CommonJS wrapper or bundler configuration, or specific Node.js settings.","wrong":"import Table from 'cli-tableau';","symbol":"Table","correct":"const Table = require('cli-tableau');"},{"note":"The library exports a default constructor function, not named exports. Attempting a named import like `{ Table }` will result in `Table` being `undefined` in ES modules.","wrong":"import { Table } from 'cli-tableau';","symbol":"Table (named import - incorrect)","correct":"const Table = require('cli-tableau'); // Only a default export"}],"quickstart":{"code":"const Table = require('cli-tableau');\n\nconst table = new Table({\n    head: ['Task Description', 'Status', 'Due Date'],\n    colWidths: [40, 15, 20],\n    style: {\n        'padding-left': 1,\n        'padding-right': 1,\n        'head': ['cyan'],\n        'border': ['grey'],\n        'compact': true // Makes rows more compact\n    }\n});\n\ntable.push(\n    ['Implement feature X', 'In Progress', '2024-05-01'],\n    ['Fix bug Y in module Z', 'Pending Review', '2024-04-28'],\n    ['Write documentation for API V2', 'Not Started', '2024-05-15']\n);\n\nconsole.log(table.toString());\n","lang":"javascript","description":"Demonstrates creating a basic horizontal table with custom headers, column widths, and basic styling, then populating it with data rows for console output."},"warnings":[{"fix":"For ESM projects, you might need `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const Table = require('cli-tableau');` or configure your bundler to handle CJS modules.","message":"cli-tableau is predominantly a CommonJS (CJS) library. While it works seamlessly in Node.js CJS projects, direct ES module (ESM) `import` statements may require specific Node.js configurations, bundler setups, or a CJS wrapper to function correctly in pure ESM projects. Consider using `createRequire` if mixing CJS into ESM.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always test your custom `chars` configuration with various data inputs. Refer to the documentation examples for common patterns, such as removing horizontal lines between rows by clearing `mid`, `left-mid`, `mid-mid`, `right-mid`.","message":"Custom character styles (`chars`) are powerful but can lead to unexpected visual output if not all necessary characters are defined or if they conflict with `borders` and `style` settings. Setting certain `chars` properties to empty strings will remove corresponding lines or intersections.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you are using the CommonJS `const Table = require('cli-tableau');` pattern, as the library exports its main constructor as the default CommonJS export.","cause":"Attempting to use `Table` as a constructor after an incorrect ES module named import (e.g., `import { Table } from 'cli-tableau';`), or if `require` returned an unexpected value.","error":"TypeError: Table is not a constructor"},{"fix":"Verify that `require('cli-tableau')` successfully returned the Table constructor and that `new Table()` was called correctly. Check for typos in the import path or symbol, and ensure the module loaded as expected.","cause":"This typically occurs if the `table` instance was not correctly created, often due to an issue with the `Table` constructor call, or if `Table` itself was `undefined` (e.g., from a failed import).","error":"Cannot read properties of undefined (reading 'push')"}],"ecosystem":"npm","meta_description":null}