{"id":22608311,"url":"https://github.com/sindresorhus/update-notifier","last_synced_at":"2026-03-12T09:47:25.458Z","repository":{"id":5852699,"uuid":"7069389","full_name":"sindresorhus/update-notifier","owner":"sindresorhus","description":"Update notifications for your CLI app","archived":false,"fork":false,"pushed_at":"2024-12-07T17:32:30.000Z","size":221,"stargazers_count":1793,"open_issues_count":21,"forks_count":129,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-12-10T06:10:53.422Z","etag":null,"topics":["command-line-utility","node-module","notifications","npm-package","update-chec","update-notifier","updater"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2012-12-08T16:23:20.000Z","updated_at":"2025-12-09T17:50:21.000Z","dependencies_parsed_at":"2024-06-18T11:02:53.249Z","dependency_job_id":"671c45e5-f26b-4ed4-81a6-36763f4d62c9","html_url":"https://github.com/sindresorhus/update-notifier","commit_stats":{"total_commits":204,"total_committers":52,"mean_commits":3.923076923076923,"dds":"0.43137254901960786","last_synced_commit":"cfa174a85844653bb5808c6d19076101b75e93df"},"previous_names":["sindresorhus/update-notifier","yeoman/update-notifier"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/sindresorhus/update-notifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fupdate-notifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fupdate-notifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fupdate-notifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fupdate-notifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/update-notifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fupdate-notifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27689467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-12T02:00:06.775Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-utility","node-module","notifications","npm-package","update-chec","update-notifier","updater"],"created_at":"2024-12-08T15:00:51.934Z","updated_at":"2025-12-23T03:03:33.248Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript"],"sub_categories":[],"readme":"# update-notifier\n\n\u003e Update notifications for your CLI app\n\n![](screenshot.png)\n\nInform users of updates for your package in a non-intrusive way.\n\n#### Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [How](#how)\n- [API](#api)\n- [About](#about)\n- [Users](#users)\n\n## Install\n\n```sh\nnpm install update-notifier\n```\n\n## Usage\n\n### Basic\n\n```js\nimport updateNotifier from 'update-notifier';\nimport packageJson from './package.json' assert {type: 'json'};\n\nupdateNotifier({pkg: packageJson}).notify();\n```\n\n### Advanced\n\n```js\nimport updateNotifier from 'update-notifier';\nimport packageJson from './package.json' assert {type: 'json'};\n\n// Checks for available update and returns an instance\nconst notifier = updateNotifier({pkg: packageJson});\n\n// Notify using the built-in convenience method\nnotifier.notify();\n\n// `notifier.update` contains some useful info about the update\nconsole.log(notifier.update);\n/*\n{\n\tlatest: '1.0.1',\n\tcurrent: '1.0.0',\n\ttype: 'patch', // Possible values: latest, major, minor, patch, prerelease, build\n\tname: 'pageres'\n}\n*/\n```\n\n### Options and custom message\n\n```js\nconst notifier = updateNotifier({\n\tpkg,\n\tupdateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week\n});\n\nif (notifier.update) {\n\tconsole.log(`Update available: ${notifier.update.latest}`);\n}\n```\n\n## How it works\n\nWhenever you initiate the update notifier and it's not within the interval threshold, it will asynchronously check with npm in the background for available updates, then persist the result. The next time the notifier is initiated, the result will be loaded into the `.update` property. This prevents any impact on your package startup performance.\nThe update check is done in an unref'ed [child process](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). This means that if you call `process.exit`, the check will still be performed in its own process.\n\nThe first time the user runs your app, it will check for an update, and even if an update is available, it will wait the specified `updateCheckInterval` before notifying the user. This is done to not be annoying to the user, but might surprise you as an implementer if you're testing whether it works. Check out [`example.js`](example.js) to quickly test out `update-notifier` and see how you can test that it works in your app.\n\n## API\n\n### notifier = updateNotifier(options)\n\nChecks if there is an available update. Accepts options defined below. Returns an instance with an `.update` property if there is an available update, otherwise `undefined`.\n\n### options\n\nType: `object`\n\n#### pkg\n\nType: `object`\n\n##### name\n\n*Required*\\\nType: `string`\n\n##### version\n\n*Required*\\\nType: `string`\n\n#### updateCheckInterval\n\nType: `number`\\\nDefault: `1000 * 60 * 60 * 24` *(1 day)*\n\nHow often to check for updates.\n\n#### shouldNotifyInNpmScript\n\nType: `boolean`\\\nDefault: `false`\n\nAllows notification to be shown when running as an npm script.\n\n#### distTag\n\nType: `string`\\\nDefault: `'latest'`\n\nWhich [dist-tag](https://docs.npmjs.com/adding-dist-tags-to-packages) to use to find the latest version.\n\n### notifier.fetchInfo()\n\nCheck update information.\n\nReturns an `object` with:\n\n- `latest` *(string)* - Latest version.\n- `current` *(string)* - Current version.\n- `type` *(string)* - Type of the current update. Possible values: `latest`, `major`, `minor`, `patch`, `prerelease`, `build`.\n- `name` *(string)* - Package name.\n\n### notifier.notify(options?)\n\nConvenience method to display a notification message. *(See screenshot)*\n\nOnly notifies if there is an update and the process is [TTY](https://nodejs.org/api/process.html#process_a_note_on_process_i_o).\n\n#### options\n\nType: `object`\n\n##### defer\n\nType: `boolean`\\\nDefault: `true`\n\nDefer showing the notification until after the process has exited.\n\n##### message\n\nType: `string`\\\nDefault: [See above screenshot](#update-notifier-)\n\nMessage that will be shown when an update is available.\n\nAvailable placeholders:\n\n- `{packageName}` - Package name.\n- `{currentVersion}` - Current version.\n- `{latestVersion}` - Latest version.\n- `{updateCommand}` - Update command.\n\n```js\nnotifier.notify({message: 'Run `{updateCommand}` to update.'});\n\n// Output:\n// Run `npm install update-notifier-tester@1.0.0` to update.\n```\n\n##### isGlobal\n\nType: `boolean`\\\nDefault: Auto-detect\n\nInclude the `-g` argument in the default message's `npm i` recommendation. You may want to change this if your CLI package can be installed as a dependency of another project, and don't want to recommend a global installation. This option is ignored if you supply your own `message` (see above).\n\n##### boxenOptions\n\nType: `object`\\\nDefault: `{padding: 1, margin: 1, textAlignment: 'center', borderColor: 'yellow', borderStyle: 'round'}` *(See screenshot)*\n\nOptions object that will be passed to [`boxen`](https://github.com/sindresorhus/boxen).\n\n### User settings\n\nUsers of your module have the ability to opt-out of the update notifier by changing the `optOut` property to `true` in `~/.config/configstore/update-notifier-[your-module-name].json`. The path is available in `notifier.config.path`.\n\nUsers can also opt-out by [setting the environment variable](https://github.com/sindresorhus/guides/blob/main/set-environment-variables.md) `NO_UPDATE_NOTIFIER` with any value or by using the `--no-update-notifier` flag on a per run basis.\n\nThe check is also skipped automatically:\n- [in CI](https://github.com/sindresorhus/is-in-ci)\n- in unit tests (when the `NODE_ENV` environment variable is `test`)\n\n## About\n\nThe idea for this module came from the desire to apply the browser update strategy to CLI tools, where everyone is always on the latest version. We first tried automatic updating, which we discovered wasn't popular. This is the second iteration of that idea, but limited to just update notifications.\n\n## Users\n\nThere are a bunch of projects using it:\n\n- [npm](https://github.com/npm/npm) - Package manager for JavaScript\n- [Yeoman](https://yeoman.io) - Modern workflows for modern webapps\n- [AVA](https://avajs.dev) - Simple concurrent test runner\n- [XO](https://github.com/xojs/xo) - JavaScript happiness style linter\n- [Node GH](https://github.com/node-gh/gh) - GitHub command line tool\n\n[And 5000+ more…](https://www.npmjs.org/browse/depended/update-notifier)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fupdate-notifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fupdate-notifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fupdate-notifier/lists"}