Check if a newer version of a npm package is available

Usage no npm install needed!

<script type="module">
  import xpackUpdateChecker from 'https://cdn.skypack.dev/@xpack/update-checker';


npm (scoped) license Standard Actions Status GitHub issues GitHub pulls

Check if a newer version of a npm package is available

A Node.js module with a class to check if a more recent version of a npm package is available.


A recent Node.js (>=10.x), since the ECMAScript 6 class syntax is used.

Easy install

The module is available as @xpack/update-checker from the public repository, use npm to install it inside the module where it is needed:

cd <npm-package-project>
npm install @xpack/update-checker

The module does not provide any executables, and generally there are few reasons to install it globally.

The development repository is available from the GitHub xpack/update-checker-js project.

User info

The module can be included in any application and the class can be used directly or custom class can be derived from it for custom behaviour.

A typical use case is a CLI application.

The logger must have at least the log.warning(), log.info(), log.debug(), and log.trace() methods; a good candidate is a logger derived from @xpack/logger.


const UpdateChecker = require('@xpack/update-checker').UpdateChecker
const Logger = require('@xpack/logger').Logger

async main(argv) {
  const log = new Logger({
    level: 'info'

  // ... Other initializations.

  // Read in the current package JSON (bring your own function here).
  const package = await readPackageJson()

  // Create the notifier object, tuned to the current package.
  updateChecker = new UpdateChecker({
    log: log,
    packageName: package.name,
    packageVersion: package.version

  await updateChecker.initiateVersionRetrieval()

  // ... Perform the application actual work.

  // Before returning, possibly send a notification to the console.
  await updateChecker.notifyIfUpdateIsAvailable()

  return exitCode

The check is not done if one of the foollowing conditions are met:

  • running in a CI environment
  • stdout is not a TTY
  • the process is running as root
  • the program is installed in system locations
  • the NO_NPM_UPDATE_NOTIFIER variable is present in the environment map

These checks are performed by specialised modules, but it is possible to override them by passing boolean properties to the constructor:

  • isCI
  • isTTY
  • isRunningAsRoot
  • isInstalledGlobally
  • isInstalledAsRoot

The valability of the check can also be configured via a property:

  • checkUpdatesIntervalSeconds

Maintainer info

This page documents how to use this module in an user application. For maintainer information, see the separate README-MAINTAINER page.


The original content is released under the MIT License, with all rights reserved to Liviu Ionescu.