update-notifier is a utility package designed to provide non-intrusive update notifications for command-line interface (CLI) applications. Its current stable version is 7.3.1. The package maintains an active release cadence, with several patch and minor updates between major versions, which typically occur every one to two years. A key differentiator is its asynchronous update check mechanism: it performs checks in an unref'ed child process in the background, minimizing impact on the CLI app's startup performance. It also defers initial notifications and subsequent checks based on a configurable `updateCheckInterval`, preventing annoyance and ensuring a smooth user experience. Since v7.0.0, it mandates Node.js 18 or higher, and v6.0.0 transitioned it to a pure ESM package, requiring modern JavaScript module handling. This design philosophy aims to keep CLI tools fresh for users without disrupting their workflow or the developer's application startup speed.
npm install update-notifierVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `update-notifier`, access update information, and trigger the notification process in a non-blocking way for a CLI application. It sets a short update check interval for easy testing.
Migrate your project to use ESM `import` statements and ensure your `package.json` specifies `"type": "module"` or uses `.mjs` file extensions. Refer to the 'read this' link in the v6.0.0 release notes for guidance.
Upgrade your Node.js environment to version 18 or higher to use `update-notifier` v7.x. If you must use an older Node.js version, you will need to stick to an older `update-notifier` version (e.g., v5.x for Node.js <14).
For testing, you can set a very low `updateCheckInterval` (e.g., `1000 * 10` for 10 seconds). Be aware of this behavior during initial implementation and testing cycles.
This is intentional behavior to prevent interference in automated scripts. If you need to check for updates programmatically in non-TTY environments, use `notifier.fetchInfo()` and handle the output yourself.
If supporting Yarn users is critical, you can provide a custom `message` option to `notifier.notify()` to include Yarn-specific instructions.
Convert your consuming file to an ES module (e.g., rename to `.mjs` or add `"type": "module"` to your `package.json`) and use `import updateNotifier from 'update-notifier';`.
Use `import` statements instead of `require()` for all module loading in your ES module. For `update-notifier`, use `import updateNotifier from 'update-notifier';`.
Upgrade your Node.js environment to version 18 or higher using a Node.js version manager like `nvm` or `fnm`.
Ensure `updateNotifier()` is called with a `pkg` object that has both `name` and `version` properties, for example: `updateNotifier({pkg: {name: 'my-app', version: '1.0.0'}}).notify();`No dependency data recorded yet.