cli-cursor is a lightweight utility that provides a simple API for showing, hiding, and toggling the command-line interface cursor. Its primary function is to manage cursor visibility in terminal applications, with a notable feature of gracefully restoring the cursor's state upon process exit, preventing a permanently hidden cursor. The current stable version is 5.0.0, which requires Node.js 18 or higher. Releases are typically driven by updates to Node.js LTS versions and the transition to pure ESM, rather than a fixed cadence. Key differentiators include its robust cursor restoration mechanism (powered by `restore-cursor`) and a minimalist, focused API, making it a reliable choice for CLI tools needing precise cursor control.
npm install cli-cursorVerified import paths — ran on the pinned version, not inferred.
Demonstrates hiding and toggling the CLI cursor, with graceful restoration on exit and explicit showing before the application terminates.
Upgrade Node.js to version 18 or higher, or pin `cli-cursor` to a compatible older version (e.g., `^4.0.0` for Node.js 12.20+).
Migrate your project to use ES modules (`import`) or dynamically import the package. If using CommonJS, pin `cli-cursor` to `^3.1.0`.
Upgrade Node.js to version 12.20 or higher, or downgrade `cli-cursor` to `^3.1.0` if Node.js 8+ is required.
Upgrade Node.js to version 8 or higher, or use `cli-cursor@^2.x.x`.
Include `cliCursor.show()` in your application's cleanup logic, especially before process exits that might not trigger `restore-cursor`'s hooks.
Change `const cliCursor = require('cli-cursor');` to `import cliCursor from 'cli-cursor';` and ensure your project is configured for ES modules (e.g., `"type": "module"` in `package.json` or using `.mjs` extension).Ensure you are using `import cliCursor from 'cli-cursor';` and then calling `cliCursor.hide()`, `cliCursor.show()`, or `cliCursor.toggle()`.
Verify your `tsconfig.json` includes `"esModuleInterop": true`, `"allowSyntheticDefaultImports": true`, and ensure your bundler (if any) is configured correctly for ESM. Alternatively, try `import * as cliCursor from 'cli-cursor';` though `import cliCursor from 'cli-cursor';` should work for a default export.
Either rename your file to `.mjs`, add `"type": "module"` to your `package.json`, or configure your build system (e.g., Babel, TypeScript) to transpile ESM to CommonJS if your runtime environment is strictly CommonJS.