{"id":18753,"library":"restore-cursor","title":"restore-cursor","description":"Gracefully restore the CLI cursor on exit. The package automatically restores the cursor when a process exits, preventing hidden cursors from remaining hidden after crashes or interruptions. Latest version 5.1.0, maintained by Sindre Sorhus. Releases are stable and infrequent. Key differentiators: zero dependencies (v5+), proper TTY detection (no-op in non-TTY contexts), and simple imperative API. Pure ESM from v4, requires Node.js >=18 (v5).","status":"active","version":"5.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/restore-cursor","tags":["javascript","exit","quit","process","graceful","shutdown","sigterm","sigint","terminate","typescript"],"install":[{"cmd":"npm install restore-cursor","lang":"bash","label":"npm"},{"cmd":"yarn add restore-cursor","lang":"bash","label":"yarn"},{"cmd":"pnpm add restore-cursor","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is pure ESM since v4, so require() is not supported. Use dynamic import if needed in CJS: const restoreCursor = (await import('restore-cursor')).default;","wrong":"const restoreCursor = require('restore-cursor')","symbol":"default","correct":"import restoreCursor from 'restore-cursor'"},{"note":"The default export is the function itself; there is no named export restoreCursor.","wrong":"import { restoreCursor } from 'restore-cursor'","symbol":"restoreCursor","correct":"import restoreCursor from 'restore-cursor'"},{"note":"restore-cursor ships TypeScript types, but the function is a default export (not a type). Use import type only for types, not for values.","wrong":"import type restoreCursor from 'restore-cursor'","symbol":"type","correct":"import restoreCursor from 'restore-cursor'"}],"quickstart":{"code":"import restoreCursor from 'restore-cursor';\n\n// Hide cursor (e.g., for a spinner)\nprocess.stdout.write('\\u001B[?25l');\n\n// ... do work (if the process crashes, cursor is restored automatically)\n\n// Restore cursor manually\nrestoreCursor();\n\n// Or let the cleanup happen on exit","lang":"typescript","description":"Shows how to import and call restoreCursor to gracefully restore the cursor on exit. Demonstrates manual restore and automatic cleanup."},"warnings":[{"fix":"Use dynamic import() or switch to ES modules.","message":"This package is now pure ESM. It cannot be require()'d from CommonJS.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Upgrade Node.js to >=18 or use v4.x (which requires Node.js 12.20).","message":"Requires Node.js 18 or later.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"If you rely on cursor restore in non-TTY contexts, you may need to handle that manually.","message":"No longer prints control codes to non-terminal outputs.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"No action needed; it is idempotent.","message":"Calling restoreCursor() multiple times or when cursor was not hidden has no effect, but is safe.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use dynamic import: const restoreCursor = (await import('restore-cursor')).default;","cause":"Using require() on a package that is pure ESM (v4+).","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Set \"type\": \"module\" in package.json or use .mjs extension.","cause":"Trying to import a package using ESM in a CommonJS environment without proper configuration.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}