{"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,"search_vec":"'18':69 '5.1.0':33 'api':62 'automat':13 'cli':7 'context':58 'crash':28 'cursor':3,8,16,23 'depend':46 'detect':50 'differenti':44 'esm':64 'exit':10,20,72 'grace':4,75 'hidden':22,26 'imper':61 'infrequ':42 'interrupt':30 'javascript':71 'key':43 'latest':31 'maintain':34 'no-op':51 'node.js':68 'non':56 'non-tti':55 'op':53 'packag':12 'prevent':21 'process':19,74 'proper':48 'pure':63 'quit':73 'releas':38 'remain':25 'requir':67 'restor':2,5,14 'restore-cursor':1 'shutdown':76 'sigint':78 'sigterm':77 'simpl':60 'sindr':36 'sorhus':37 'stabl':40 'termin':79 'tti':49,57 'typescript':80 'v4':66 'v5':47,70 'version':32 'zero':45","created_at":"2026-04-25T07:39:57.101153+00:00","updated_at":"2026-04-25T07:39:57.101153+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/sindresorhus/restore-cursor","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/restore-cursor","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}