Registry / web-framework / clite
library0.2.2jsnpmunverified

clite is a lightweight command-line interface (CLI) framework for Node.js applications, designed to provide essential boilerplate functionality. Its current stable version is 0.3.0, last released in March 2016, indicating that the project is likely no longer actively maintained. The library focuses on automating common CLI tasks such as displaying version information from `package.json`, generating help documentation, handling `stdin` input, notifying users of updates via `update-notifier`, and managing exceptions with non-zero exit codes. It leverages `abbrev` for command/option aliasing and `yargs` for robust argument parsing, including booleans and options. Commands are promise-based and lazy-loaded to optimize boot times. A key differentiator is its minimal configuration approach, allowing developers to quickly scaffold CLI tools without extensive setup, though its age might pose compatibility challenges with modern Node.js environments.

npm install clite
INSTALL
IMPORT
SIG · CLITE
C
clite
web-frameworkjavascriptv0.2.2
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.

clite
const clite = require('clite');
import clite from 'clite';
clite is a CommonJS module and must be imported using `require()` in Node.js environments. Direct ES module `import` syntax will result in an error.
Configuration Object
clite(require('./config'));
clite({ commands: { /* ... */ } });
The primary `clite` function expects a configuration object, typically loaded from a separate CommonJS module file using `require()`.
Command Module
module.exports = function myCommand(args) { /* ... */ };
export default function myCommand(args) { /* ... */ };
Command modules are dynamically loaded by clite and must use Node.js CommonJS `module.exports` syntax to expose their functionality.

Demonstrates setting up a basic `clite` application with a default command, a named command (`greet`), and an asynchronous command (`delay`), including configuration for options, booleans, aliases, and a help file. The code shows how `clite` consumes a configuration object and how individual command modules are structured.

/* cli.js */ #!/usr/bin/env node const clite = require('clite'); const path = require('path'); // Load configuration for the CLI application clite(require('./config')); /* config.js */ module.exports = { commands: { '_': path.join(__dirname, 'commands', 'default'), // Default command if no argument provided 'greet': path.join(__dirname, 'commands', 'greet'), 'delay': path.join(__dirname, 'commands', 'delay') }, booleans: ['verbose', 'help'], options: ['name', 'message'], alias: { 'v': 'verbose', 'n': 'name' }, help: path.join(__dirname, 'help', 'main.txt') // Path to a main help file }; /* commands/default.js */ module.exports = function defaultCommand(args) { if (args.help) { return `Usage: my-cli [command] [--name <name>] [--message <message>] [--verbose] Default command echoes arguments or shows a welcome message. Try 'my-cli greet --name World' to greet someone.`; } if (args._.length > 0) { return `You ran the default command with arguments: ${args._.join(' ')}`; } return 'Welcome to the clite demo! Try `my-cli greet --name John`.'; }; /* commands/greet.js */ module.exports = function greetCommand(args) { const name = args.name || 'Stranger'; const message = args.message || 'Hello'; if (args.verbose) { return `Preparing to greet ${name} with message: "${message}"`; } return `${message}, ${name}!`; }; /* commands/delay.js */ module.exports = function delayCommand(args) { const duration = parseInt(args._[0] || '1000', 10); // First argument is delay duration return new Promise(resolve => { setTimeout(() => resolve(`Delayed for ${duration}ms. All done!`), duration); }); }; /* help/main.txt */ // This is a simple help file for the 'my-cli' tool. // Use 'my-cli --help' for general help. // Use 'my-cli greet --help' for command specific help (if implemented).
clite --version
Debug
Known issues
breakingclite has not been updated since March 2016, making it potentially incompatible with modern Node.js versions (e.g., v16+, v18+, v20+) and newer JavaScript language features (ESM). Its internal dependencies may also be severely outdated.
fix
Consider migrating to a actively maintained CLI framework (e.g., `oclif`, `commander`, `yargs`) or thoroughly test compatibility with your target Node.js runtime and dependencies using a lockfile.
affects: >=0.3.0
gotchaBy default, clite catches all exceptions originating from command modules and exits the process with a non-zero code, printing the error message to stderr. This prevents higher-level application-specific error handling.
fix
To handle errors within your application code, set the `return: true` property in your clite configuration. This will cause errors to be returned as rejected promises to your main script instead of causing a `process.exit(1)`.
affects: >=0.1.0
gotchaclite relies on internal dependencies like `yargs` and `abbrev`. If these dependencies have had breaking changes in their latest versions that conflict with the specific versions clite expects (which are likely old), it could lead to unexpected behavior or runtime errors.
fix
Ensure your project uses a lockfile (`package-lock.json` or `yarn.lock`) to maintain consistent dependency versions. If conflicts arise, manual intervention or a full migration to a more current framework might be necessary.
affects: >=0.1.0
deprecatedThe project uses CommonJS modules exclusively, which is considered a legacy module system in modern Node.js development. It does not support native ES Modules (`import`/`export` syntax) without transpilation or specific Node.js loader configurations.
fix
Develop new CLI projects using native ES Modules with a modern CLI framework. For existing clite projects, continue using CommonJS or plan for a full migration.
affects: >=0.1.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Attempting to use ES module syntax (`import`) with clite, which is a CommonJS-only package.
fix
Change `import clite from 'clite';` to `const clite = require('clite');` in your main CLI entry file.
ReferenceError: Promise is not defined
Running clite on a very old Node.js version (pre-Node.js 4.0) where Promises were not natively supported, and the `es6-promise` polyfill included by clite is not effective or properly loaded.
fix
Ensure `es6-promise` is installed and that clite's internal polyfill is effective, or preferably, upgrade to Node.js v4.0 or higher where Promises are natively available.
Error: Cannot find module './config'
The main clite script cannot locate the configuration file specified in the `require()` call.
fix
Verify that the path to your config file passed to `require()` in your main script (e.g., `clite(require('./config'));`) is correct and relative to the calling script's location.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies
update-notifierrequiredNotifies users of new package versions for the CLI tool.
abbrevrequiredAutomatically generates command and option aliases.
yargsrequiredParses command-line arguments, including boolean flags, options, and aliases.
es6-promiserequiredPolyfills the Promise API for Node.js versions older than 4.
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources