cli-loading-animation

raw JSON →
1.0.6 verified Sat Apr 25 auth: no javascript

A Node.js library that combines cli-spinners and log-update to display terminal loading animations. Current stable version is 1.0.6. Provides a simple API with start/stop functions and supports custom spinners. Differentiators include zero additional dependencies (uses well-established underlying libraries) and TypeScript type definitions included.

error TypeError: loading is not a function
cause Incorrect import: using default import when named import is needed.
fix
Use import { loading } from 'cli-loading-animation' or const { loading } = require('cli-loading-animation').
error Cannot find module 'cli-loading-animation'
cause Package not installed or missing from node_modules.
fix
Run npm install cli-loading-animation or yarn add cli-loading-animation.
deprecated Package relies on log-update v4 which uses ansi-escapes. Future versions may change.
fix Monitor for updates to underlying dependencies.
gotcha Calling stop() multiple times will not throw but may cause unexpected behavior if clearOnEnd is true.
fix Ensure stop() is called only once.
gotcha The loading function returns an object with start and stop. Starting without stopping may leave terminal in inconsistent state.
fix Always call stop() after use, e.g., in a finally block.
npm install cli-loading-animation
yarn add cli-loading-animation
pnpm add cli-loading-animation

Shows how to import and use the loading function with a custom message and optional clearing on stop.

import { loading } from 'cli-loading-animation';

const { start, stop } = loading('Processing...', { clearOnEnd: true });
start();
setTimeout(() => {
  stop();
  console.log('Done!');
}, 3000);