{"id":17070,"library":"tiny-spinner","title":"Tiny Spinner","description":"Tiny Spinner is a minimalist CLI spinner library designed to provide visual feedback for asynchronous operations in terminal applications. It aims for simplicity and a small footprint, differentiating itself from more feature-rich alternatives like `ora` by offering a streamlined API. The package is currently at version 2.0.5 and ships with TypeScript types, facilitating its use in modern JavaScript and TypeScript projects. While its release cadence appears measured, with the last update around early 2025, it remains an active project. Its core functionality focuses on starting, updating, and gracefully stopping a spinner with various status messages (success, warning, error).","status":"active","version":"2.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/fabiospampinato/tiny-spinner","tags":["javascript","cli","terminal","spinner","loading","tiny","pretty","typescript"],"install":[{"cmd":"npm install tiny-spinner","lang":"bash","label":"npm"},{"cmd":"yarn add tiny-spinner","lang":"bash","label":"yarn"},{"cmd":"pnpm add tiny-spinner","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Since v2 (circa 2022), 'tiny-spinner' is an ES Module. For CommonJS, you must access the '.default' property or use dynamic import.","wrong":"const Spinner = require('tiny-spinner');","symbol":"Spinner","correct":"import Spinner from 'tiny-spinner';"},{"note":"For CommonJS environments, explicitly access the default export. Alternatively, `const { default: Spinner } = require('tiny-spinner');` also works.","wrong":"const Spinner = require('tiny-spinner'); // Fails to construct","symbol":"Spinner (CommonJS)","correct":"const Spinner = require('tiny-spinner').default;"},{"note":"The primary export is a default class. For type-only imports, use 'import type' and alias if 'Spinner' is already used.","wrong":"import { Spinner } from 'tiny-spinner'; // Not typically exported as named type","symbol":"Spinner (Type)","correct":"import type { Spinner as SpinnerType } from 'tiny-spinner';"}],"quickstart":{"code":"import Spinner from 'tiny-spinner';\n\nconst spinner = new Spinner ();\n\nasync function performTask() {\n  spinner.start('Doing something important...');\n\n  try {\n    await new Promise(resolve => setTimeout(resolve, 2000)); // Simulate async work\n    spinner.update('Still processing data...');\n\n    await new Promise(resolve => setTimeout(resolve, 1500)); // More work\n\n    if (Math.random() > 0.8) {\n      spinner.error('Task failed unexpectedly!');\n      process.exit(1);\n    } else if (Math.random() > 0.5) {\n      spinner.warning('Task completed with minor issues.');\n    } else {\n      spinner.success('Task completed successfully!');\n    }\n  } catch (error) {\n    spinner.error(`An unhandled error occurred: ${error.message}`);\n    process.exit(1);\n  }\n}\n\nperformTask();","lang":"typescript","description":"Demonstrates starting, updating, and gracefully stopping the spinner with success, warning, or error messages based on simulated asynchronous operations."},"warnings":[{"fix":"For CommonJS, use `const Spinner = require('tiny-spinner').default;`. For new projects, prefer ESM with `import Spinner from 'tiny-spinner';` and set `\"type\": \"module\"` in your `package.json`.","message":"The package transitioned to an ES Module (ESM) approximately four years ago, likely with its v2 release. This means direct `require('tiny-spinner')` in a CommonJS context will not correctly yield the `Spinner` class instance without explicitly accessing the `.default` property.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure all logging is performed either before the spinner starts or after it stops. If logging is required mid-spin, you might need to manually stop the spinner, log, and then restart it, or consider a more robust spinner library (e.g., `ora`) that handles this gracefully.","message":"Direct `console.log` or `process.stdout.write` calls while the spinner is active can interfere with the spinner's animation, leading to visual glitches or broken output. Unlike some more advanced spinner libraries, `tiny-spinner` does not automatically handle interleaved output.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always ensure that one of the spinner's termination methods is called in all possible code paths (e.g., in `finally` blocks, success callbacks, or error handlers) to properly clean up the terminal line.","message":"Failing to call any of the termination methods (`spinner.stop()`, `spinner.success()`, `spinner.error()`, `spinner.warning()`) will leave the spinner running indefinitely in the terminal, blocking further output or misleading the user about task completion.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Correctly access the default export in CommonJS: `const Spinner = require('tiny-spinner').default;` or `const { default: Spinner } = require('tiny-spinner');`.","cause":"Attempting to use `require('tiny-spinner')` and instantiate it directly without accessing the default export in a CommonJS module after the package became ESM.","error":"TypeError: tiny_spinner_1.default is not a constructor"},{"fix":"Either convert your project or file to an ES Module by adding `\"type\": \"module\"` to your `package.json` or by using the `.mjs` file extension. Alternatively, for CommonJS, use the `require` syntax: `const Spinner = require('tiny-spinner').default;`.","cause":"Using `import Spinner from 'tiny-spinner';` in a JavaScript file that is treated as a CommonJS module (e.g., a `.js` file without `\"type\": \"module\"` in `package.json` in Node.js).","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null}