Use npm to version all kinds of projects, not just javascript.

Usage no npm install needed!

<script type="module">
  import versionEverything from '';



Version: 0.6.4

Use npm to version all kinds of projects, not just JavaScript

Travis Build Status codecov Coveralls github Code Climate maintainability
npm dependencies Status styled with prettier

Synchronize the version string from package.json into a set of additional text or structured data files. When called from npm's version script, all versioned files in a project will be updated and committed with a single command.

    npm install --save version-everything

How to version everything

There are several ways version-everything can be used, the only requirement is an array of files to synchronize versions into. The files can be text (php, css, markdown, whatever) or structured data (JSON or yaml).

The file list is an array specified in one of the following forms, in order of precedence:

  1. Command line arguments
  2. files key in a version-everything.config.js file
  3. version-everything.files key in the parent project's package.json file

npm lifecycle script in package.json

The simplest way to use version-everything is to hook into npm's version event. Once set up, a single npm command will update, commit and tag all versioned files in a project.

Add something like the following to your project's package.json file:

  "version": "1.3.6",
  "scripts": {
    "version": "version-everything && git add -u"
  "version-everything": {
    "files": [

Then run a command like npm version minor to bump the version in all the files. It's that easy.

Note that structured data files will be formatted using default settings.

Replacing version strings

In text files, the following version strings will be updated.

  • Version: 1.2.34
  • ### Version: 2.34.5 (Markdown headings)
  • * @version 4.5.67
  • v0.6.0 (At end-of-line)
  • LABEL version="1.2.34" (Dockerfiles)

Notes: Colons are optional. Simple v-prefixed, git-tag style version strings must appear at the end of a line.

version-everything config files

This project uses the cosmiconfig library to load config files.the file-key should be version-everything, so files like .version-everythingrc or .version-everythingrc.js will work.

The file should export a simple JS object and look something like this:

module.exports = {
  files: ["", "example_wordpress_plugin.php", "styles.css"],
  json: {
    /* optional json config object, keys pass directly to JSON.stringify */
  yaml: {
    /* optional yaml config object, passes directly to js-yaml */
  xml: {
    /* optional xml config object, passes directly to xml2js */

Calling the version-everything binary prefers this file over settings in package.json.

CommonJS module requires

Version-everything can also be used like any other Node module. The version string will be pulled from package.json and should be treated as a global constant or envvar.

const version = require("version-everything");

version(["", "manifest.json"], { json: { space: 4 } });

Command Line Interface

When run from the command line, all arguments following the command are assumed to be file paths. This command would sync versions into and manifest.json:

$ version-everything manifest.json

Conflicting arguments

If a package.json is specified, it will be loaded first, then any subsequent args will be applied on top. So if package.json were to contain a version-everything.files array, that array would be overwritten by any list of files provided to the command line.

Recognized File Extensions

Files with the following extensions will be recognized as structured text and parsed accordingly.

  • JSON - .json
  • XML - .xml, .plist
  • YAML - .yml, .yaml


versionEverything(files, [options])


Type: array

An array containing the files which will be versioned.


Type: object All keys are optional.


Type: object Three keys from the json object will be passed directly to JSON.parse or JSON.stringify: space which sets indentation from an integer or string, a reviver function and a replacer function/array. See the JSON docs for more info.


Type: object Passed directly to the xml2js Builder class. See xml2js docs for available options.


Type: object Passed directly to the js-yaml safeDump method. See js-yaml docs for available options.


npm may fail to commit/tag files when package.json is nested below the git repository root. Ref: npm#18795

Enabling push.followTags in Git's global config is highly recommended: git config --global push.followTags true

While this module strongly encourages the use of true SemVer versions, these are not enforced. Just about any wacky version string without a whitespace character should work.

phpDocumentor @version tag vcs-prefixes and version-descriptions will be dropped.