Registry / devops / cli-alerts

cli-alerts

JSON →
library2.0.0jsnpmunverified

cli-alerts is a lightweight, cross-platform utility for Node.js command-line interfaces, designed to display formatted alerts with colored text and symbolic icons. It supports various alert types including success, info, warning, and error, ensuring consistent visual feedback across macOS, Linux, and Windows terminals. The current stable version is 2.0.0. While not following a strict time-based release cadence, the project maintains an active development status with periodic improvements and bug fixes. Its key differentiators include its simplicity, minimal dependencies, and direct focus on enhancing the user experience of CLI tools by providing clear, visually distinct messages without complex configurations, making it an excellent choice for developers looking to add immediate, actionable feedback to their scripts and applications.

npm install cli-alerts
INSTALL
IMPORT
SIG · CLI-ALERTS
C
cli-alerts
devopsjavascriptv2.0.0
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.

alert
import alert from 'cli-alerts'
import { alert } from 'cli-alerts'
The primary alert function is typically imported as a default export in ESM contexts, mirroring its CommonJS `require` usage.
alert (CommonJS)
const alert = require('cli-alerts');
This is the documented CommonJS usage, compatible with older Node.js projects.
AlertOptions (type)
import type { AlertOptions } from 'cli-alerts';
Since the package ships with TypeScript types, you can import the `AlertOptions` interface for strict type checking of the configuration object.

Demonstrates how to import and use the 'alert' function for various message types with TypeScript.

import alert from 'cli-alerts'; type AlertOptions = { type: 'success' | 'info' | 'warning' | 'error'; msg: string; name?: string; }; const showAlert = (options: AlertOptions) => { alert(options); }; // Example usage: console.log('\n--- CLI Alerts Examples ---'); showAlert({ type: 'success', msg: 'Operation completed successfully!' }); showAlert({ type: 'info', msg: 'Checking for updates...' }); showAlert({ type: 'warning', msg: 'Configuration file missing, using defaults.', name: 'CONFIG' }); showAlert({ type: 'error', msg: 'Failed to connect to the server. Please try again.' }); console.log('--- End Examples ---\n'); // To run this: // 1. npm install cli-alerts // 2. Save as 'app.ts' // 3. npx ts-node app.ts
clialerts --version
Debug
Known issues
breakingThe package moved to v2.0.0, indicating potential breaking changes according to semantic versioning. While specific details were not provided in the readily available documentation, users upgrading from v1.x should review the changelog for any API alterations.
fix
Consult the project's official changelog (changelog.md within the repository) for a detailed list of breaking changes and migration steps before upgrading.
affects: >=2.0.0
gotchaWhen using ESM in a Node.js project, ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions. Mixing CommonJS `require()` with ESM `import` in the same file can lead to `ERR_REQUIRE_ESM` errors.
fix
For ESM projects, use `import alert from 'cli-alerts';`. For CommonJS projects, stick to `const alert = require('cli-alerts');`. If you encounter `ERR_REQUIRE_ESM`, refactor your module imports to be consistent or ensure your environment supports interoperability (e.g., Node.js >=14 with appropriate flags or transpilation).
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported
Attempting to `require()` an ESM-only module in a CommonJS context, or vice-versa, without proper configuration or transpilation.
fix
If your project is ESM, change `const alert = require('cli-alerts');` to `import alert from 'cli-alerts';`. If your project is CommonJS, ensure `cli-alerts` itself is not an ESM-only package that's incompatible, or use a tool like `ts-node` or `esm` package for better interoperability.
TypeError: alert is not a function
Incorrect import statement (e.g., named import `{ alert }` instead of default import `alert`), or attempting to call `alert` on a non-function.
fix
Verify your import statement matches the module's export style. For `cli-alerts`, in ESM, use `import alert from 'cli-alerts';` (default import). In CommonJS, use `const alert = require('cli-alerts');`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
cli-alerts — npm install cli-alerts · libregistry