{"id":16852,"library":"meow","title":"Meow CLI Helper","description":"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.","status":"active","version":"14.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/meow","tags":["javascript","cli","bin","util","utility","helper","argv","command","line"],"install":[{"cmd":"npm install meow","lang":"bash","label":"npm"},{"cmd":"yarn add meow","lang":"bash","label":"yarn"},{"cmd":"pnpm add meow","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"`meow` is an ESM-only package since v12. Using `require()` will result in an `ERR_REQUIRE_ESM` error. Your project must be configured for ESM.","wrong":"const meow = require('meow');","symbol":"meow","correct":"import meow from 'meow';"},{"note":"Imports the TypeScript type for a single flag definition. Often used with generics for stricter type checking.","symbol":"AnyFlag","correct":"import type { AnyFlag } from 'meow';"},{"note":"Imports the TypeScript type for the entire flags object. Useful for type-checking the `cli.flags` return value.","symbol":"AnyFlags","correct":"import type { AnyFlags } from 'meow';"}],"quickstart":{"code":"#!/usr/bin/env node\nimport meow from 'meow';\n\nconst cli = meow(`\n\tUsage\n\t  $ foo <input>\n\n\tOptions\n\t  --rainbow, -r  Include a rainbow\n\n\tExamples\n\t  $ foo unicorns --rainbow\n\t  🌈 unicorns 🌈\n`, {\n\timportMeta: import.meta, // This is required for meow to find package.json\n\tflags: {\n\t\trainbow: {\n\t\t\ttype: 'boolean',\n\t\t\tshortFlag: 'r'\n\t\t}\n\t}\n});\n\n// Example usage with parsed input and flags\nconst inputArgument = cli.input.at(0);\nconst enableRainbow = cli.flags.rainbow;\n\nif (inputArgument) {\n  const message = enableRainbow ? `🌈 ${inputArgument} 🌈` : inputArgument;\n  console.log(message);\n} else {\n  console.log('No input provided. Try: foo unicorns --rainbow');\n  cli.showHelp();\n}\n","lang":"typescript","description":"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."},"warnings":[{"fix":"Upgrade your Node.js environment to version 20 or higher. Consider using a Node.js version manager (e.g., `nvm` or `volta`) to manage different project requirements.","message":"Meow v14 and later require Node.js 20 or newer. Earlier versions of Node.js are no longer supported.","severity":"breaking","affected_versions":">=14.0.0"},{"fix":"Migrate your project to use ESM syntax (`import`/`export`) and ensure your `package.json` includes `\"type\": \"module\"`. For TypeScript, configure `\"module\": \"node16\"` or `\"nodenext\"` in `tsconfig.json`.","message":"Meow is an ECMAScript Module (ESM) only package since v12. Attempting to use `require()` will result in a runtime error (`ERR_REQUIRE_ESM`).","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"Update flag definitions from `alias: 'x'` to `shortFlag: 'x'` in your `meow` configuration. If you intended to have multiple aliases, use the new `aliases` option.","message":"The `alias` flag option was renamed to `shortFlag` in v12 to provide more precise terminology. A separate `aliases` option is now available for actual multi-character aliases.","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"Always pass `{ importMeta: import.meta }` to the `meow` constructor when initializing your CLI application.","message":"The `importMeta` option is now a required configuration property for the `meow` constructor (since v12). It is used to correctly locate the `package.json` for version and help information.","severity":"breaking","affected_versions":">=12.0.0"},{"fix":"Remove the `hardRejection` option from your `meow` configuration. No functional changes are expected if your Node.js version is 16 or newer.","message":"The `hardRejection` option was removed in v13.1.0 because its functionality became the default behavior for unhandled promise rejections in Node.js 16 and later.","severity":"gotcha","affected_versions":">=13.1.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Refactor your application to use ES Modules (`import meow from 'meow';`) and ensure your `package.json` has `\"type\": \"module\"`. If using TypeScript, set `\"module\": \"node16\"` or `\"nodenext\"` and `\"moduleResolution\": \"node16\"` or `\"nodenext\"` in `tsconfig.json`.","cause":"Attempting to import `meow` using CommonJS `require()` syntax in an ES Module context, or in a CommonJS project that doesn't correctly handle ESM imports.","error":"ERR_REQUIRE_ESM: require() of ES Module .../node_modules/meow/index.js from ... not supported."},{"fix":"Add `{ importMeta: import.meta }` to the `meow` constructor. This property is crucial for `meow` to correctly resolve paths to your `package.json` for displaying help and version information.","cause":"The `importMeta: import.meta` option was omitted from the `meow` constructor call.","error":"Error: The `importMeta` option is required."},{"fix":"Upgrade your Node.js environment to version 20 or higher. You can use tools like `nvm install 20` or `volta install node@20`.","cause":"The installed Node.js version does not meet the minimum requirement specified by `meow`.","error":"Error [ERR_OS_NOT_SUPPORTED]: Your current Node.js version is X.Y.Z, but meow requires >=20. The latest Node.js LTS version is recommended."},{"fix":"Replace the `alias` property with `shortFlag` in your flag definitions (e.g., `shortFlag: 'r'` instead of `alias: 'r'`). If you need multiple aliases, use the new `aliases` option.","cause":"An older `meow` configuration or code attempting to use the `alias` property within flag definitions after `meow` v12, where it was renamed.","error":"TypeError: 'alias' is not a valid flag option. Did you mean 'shortFlag'?"},{"fix":"Ensure that the necessary input arguments are always provided to the CLI. If the input is not strictly mandatory in all scenarios, consider setting `input.isRequired: false` or making it a function that dynamically determines requirement.","cause":"The `input.isRequired` option is set to `true` in the `meow` configuration, but no non-flag arguments were provided when running the CLI.","error":"Error: Input required."}],"ecosystem":"npm","meta_description":null}