Yeoman Character for CLI
The `yeoman-character` package provides a customizable, multi-line ASCII art representation of the Yeoman mascot for command-line interfaces. The current stable version is 2.0.0, which introduced significant breaking changes by moving to pure ES Modules and requiring Node.js 18. As a focused utility package for a specific visual element, its release cadence is typically slow, primarily addressing compatibility updates rather than frequent feature additions. Its key differentiator is its singular purpose: delivering the iconic Yeoman character simply and effectively to any Node.js CLI, making it a staple for branding tools within the Yeoman ecosystem or for adding a distinctive visual flair to console output.
Common errors
-
ERR_REQUIRE_ESM
cause Attempting to use `require('yeoman-character')` in a CommonJS file when the package is pure ES Modules.fixChange `require('yeoman-character')` to `import yeomanCharacter from 'yeoman-character';` and ensure your project uses ES Modules (e.g., by setting `"type": "module"` in `package.json` or using `.mjs` file extensions). For CJS compatibility, use `import('yeoman-character').then(mod => console.log(mod.default))`. -
SyntaxError: Cannot use import statement outside a module
cause Attempting to use ES `import` syntax (e.g., `import yeomanCharacter from 'yeoman-character';`) in a file that is being interpreted as CommonJS.fixEnsure the file using `import` is treated as an ES Module by either renaming it to `.mjs` or by adding `"type": "module"` to your project's `package.json`.
Warnings
- breaking This package is now pure ES Modules (ESM) and no longer supports CommonJS `require()` directly.
- breaking The minimum required Node.js version has been increased to 18.
- gotcha The exported `yeomanCharacter` string does not contain ANSI color codes by default in v2.x, despite screenshots often showing a colored character.
Install
-
npm install yeoman-character -
yarn add yeoman-character -
pnpm add yeoman-character
Imports
- yeomanCharacter
const yeomanCharacter = require('yeoman-character');import yeomanCharacter from 'yeoman-character';
Quickstart
// To run this example:
// 1. Ensure your Node.js version is 18 or higher.
// 2. Save this code as `index.mjs` (note the `.mjs` extension for ESM).
// 3. In your project directory, run: `npm install yeoman-character`
// 4. Then execute from your terminal: `node index.mjs`
import yeomanCharacter from 'yeoman-character';
console.log("-----------------------------------------");
console.log(" Displaying the Yeoman Character:");
console.log("-----------------------------------------");
// The `yeomanCharacter` export is a simple multiline string containing
// the ASCII art representation of the Yeoman mascot. While the character
// itself does not contain ANSI color codes by default in this package
// version, it is commonly used with terminal coloring libraries
// like 'chalk' or 'picocolors' for visual effect in CLIs.
console.log(yeomanCharacter);
console.log("\nThis character can also be displayed directly via its CLI:");
console.log("To install globally: `npm install --global yeoman-character`");
console.log("Then run from any terminal: `yeoman-character`");
console.log("-----------------------------------------");