simple-update-notifier is a lightweight and straightforward utility designed to inform users of command-line interface (CLI) applications about available updates on npm. It works by checking the npm registry for newer versions of a specified package and, if an update is found, prints a non-intrusive notification to the terminal. The library is currently at version 2.0.0, released in June 2023, and maintains a fairly active release cadence with minor and patch updates for dependency management and minor enhancements, and less frequent major releases for breaking changes. A key differentiator is its simplicity and built-in caching mechanism, which prevents excessive API calls to npm by only checking for updates at a configurable interval (defaulting to once a day). It also includes options to control notification behavior in npm scripts and specify different npm `dist-tags`.
npm install simple-update-notifierVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `simple-update-notifier` into a CLI application. It shows importing the notifier and passing a `pkg` object (typically from `package.json`) along with optional configuration like `updateCheckInterval` and `shouldNotifyInNpmScript`.
Ensure your project's Node.js environment is version 10 or higher. If you are on an older Node.js version, you must either upgrade Node.js or remain on `simple-update-notifier` v1.x.
Always pass an object with `name` and `version` properties as the `pkg` option, typically by importing your application's `package.json` file.
If you explicitly want to see update notifications while running within an npm script, set the `shouldNotifyInNpmScript` option to `true`.
Update your JSON imports to `import packageJson from './package.json' assert { type: 'json' };` if your project uses ESM and runs on Node.js.Pass a valid object containing `name` and `version` properties to the `pkg` option, typically derived from your application's `package.json`.
Upgrade your Node.js environment to version 16.15 or higher. If using a bundler, ensure it's configured to handle JSON modules with import assertions. Alternatively, if your project is CommonJS, use `const packageJson = require('./package.json');`.No dependency data recorded yet.