Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including version-changed with all npm packages installed. Try it out:

var versionChanged = require("version-changed")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

version-changed v2.0.0

Checks if the version in `package.json` has changed since the last commit.


Checks if the version in package.json has changed since the last commit.

Node version Build Status JavaScript Style Guide


$ npm i version-changed -S|-D|-g


In code:

const versionChanged = require('version-changed')
versionChanged((err, changed) => {
  if (err) throw err
  console.log('version changed', changed)

On command line:

$ version-changed && ./dosomething

When used in package.json it's more handy to shortcut with ||. For this reason you can use version-unchanged.

The prebuild script below will run prebuildify if the version has changed, but will not fail if the version didn't change.

  "scripts": {
    "prebuild": "version-unchanged || prebuildify --napi"


versionChanged(err, cb)

Calls back with (err, changed) where changed is true if the version in package.json at the current commit has changed compared to the previous commit, otherwise false.



Exits with 0 if the version has changed. Use this together with &&.


Exits with 0 if the version is unchanged. Use this together with ||.


This code was extracted from prebuild-ci. Kudos to @juliangruber. :heart:



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free