Meow CLI Helper

14.1.0 · active · verified Wed Apr 22

Meow is a minimalist and dependency-free helper library designed for creating command-line interface (CLI) applications in Node.js. It simplifies argument parsing, flag handling, and generation of help and version output. Currently stable at version 14.1.0, Meow maintains an active release cadence, often aligning major versions with Node.js LTS releases to keep up with runtime changes. Its key differentiators include automatic conversion of flags to camelCase, support for `--no-` prefix flag negation, and built-in `--version` and `--help` handling. Since version 12, Meow has been ESM-only, requiring modern Node.js module syntax and an `import.meta` object for package metadata resolution. Recent additions include robust subcommand parsing via the `commands` option and the ability to make input arguments required. It's an opinionated, lightweight choice for CLI parsing.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates basic CLI setup with `meow`, parsing a main input argument and a boolean flag, and printing a message. It includes the mandatory `import.meta` option.

#!/usr/bin/env node
import meow from 'meow';

const cli = meow(`
	Usage
	  $ foo <input>

	Options
	  --rainbow, -r  Include a rainbow

	Examples
	  $ foo unicorns --rainbow
	  🌈 unicorns 🌈
`, {
	importMeta: import.meta, // This is required for meow to find package.json
	flags: {
		rainbow: {
			type: 'boolean',
			shortFlag: 'r'
		}
	}
});

// Example usage with parsed input and flags
const inputArgument = cli.input.at(0);
const enableRainbow = cli.flags.rainbow;

if (inputArgument) {
  const message = enableRainbow ? `🌈 ${inputArgument} 🌈` : inputArgument;
  console.log(message);
} else {
  console.log('No input provided. Try: foo unicorns --rainbow');
  cli.showHelp();
}

view raw JSON →