whatversions
Dead simple script to show you the difference between your package.json dependency versions specified and what you actually have in node_modules. Helps you track down weird inconsistencies in your dependency versions.
Installation
npm install -g whatversions
CLI Usage
Just run whatversions
from any repo with a package.json
in it. You can also specify a path to a given directory with a package.json
in it if you don't want to navigate to the directory before running the command.
> whatversionsinfo fyi Showing specified dependency versions vs. actual installed versions.name specified actual semver------------------------------------ --------- ------- -------amd-inject-loader 0.2.2 0.2.2 perfectautoprefixer 6.3.3 6.3.3 perfectbabel-core 6.5.2 6.5.2 perfectbabel-loader 6.2.3 6.2.3 perfectbabel-preset-es2015 6.5.0 missing missingchai 3.0.0 3.0.0 perfectcolors 0.6.2 0.6.2 perfectcss-loader 0.23.1 0.23.1 perfectexports-loader 0.6.2 0.6.3 invalidexpose-loader 0.7.1 0.7.1 perfectextend 3.0.0 3.0.0 perfectextract-text-webpack-plugin 0.9.1 0.9.1 perfectgrunt 0.4.5 0.4.5 perfectgrunt-cli 0.1.9 0.1.9 perfectgrunt-concurrent 2.2.1 2.2.1 perfectgrunt-contrib-clean 1.0.0 1.0.0 perfectgrunt-contrib-concat 1.0.0 1.0.0 perfectgrunt-contrib-copy 0.8.0 0.8.0 perfectgrunt-contrib-cssmin 0.14.0 0.14.0 perfectgrunt-contrib-imagemin 1.0.0 1.0.0 perfectgrunt-contrib-jshint 1.0.0 1.0.0 perfectgrunt-contrib-requirejs 0.4.4 0.4.4 perfectgrunt-contrib-uglify 0.9.1 0.9.1 perfectgrunt-contrib-watch 0.6.1 0.6.1 perfectgrunt-jsbeautifier 0.2.8 0.2.8 perfectgrunt-jsdoc 1.0.0 1.0.0 perfectgrunt-karma 0.12.0 0.12.0 perfectgrunt-postcss 0.7.2 0.7.2 perfectgrunt-svgstore 0.5.0 0.5.0 perfectgrunt-webpack 1.0.11 1.0.11 perfectgrunt-wellington 0.2.0 0.2.0 perfecthandlebars 2.0.0 2.0.0 perfecthooker 0.2.3 0.2.3 perfectinject-loader 2.0.1 2.0.1 perfectisparta-loader 2.0.0 2.0.0 perfectistanbul-instrumenter-loader 0.2.0 0.2.0 perfectjquery 1.11.1 1.11.1 perfectjs-beautify 1.6.2 1.6.2 perfectjshint-stylish 2.0.1 2.0.1 perfectkarma 0.13.21 0.13.21 perfectkarma-chai-sinon 0.1.5 0.1.5 perfectkarma-chrome-launcher 0.2.0 0.2.0 perfectkarma-coverage 0.5.2 0.5.2 perfectkarma-firefox-launcher 0.1.3 0.1.3 perfectkarma-mocha 0.2.2 0.2.2 perfectkarma-nyan-reporter 0.2.1 0.2.1 perfectkarma-phantomjs-launcher 1.0.0 1.0.0 perfectkarma-safari-launcher 0.1.1 0.1.1 perfectkarma-sourcemap-loader 0.3.7 0.3.7 perfectkarma-spec-reporter 0.0.24 0.0.24 perfectkarma-teamcity-reporter 0.2.0 0.2.0 perfectkarma-webpack 1.7.0 1.7.0 perfectload-grunt-config 0.19.0 0.19.0 perfectload-grunt-tasks 3.1.0 3.1.0 perfectlodash 4.6.1 4.6.1 perfectmadge 0.5.0 0.5.0 perfectminami 1.1.1 1.1.1 perfectmkpath 1.0.0 1.0.0 perfectmocha 2.4.5 2.4.5 perfectnode-sass 3.4.2 3.4.2 perfectphantomjs-prebuilt 2.1.4 2.1.4 perfectpostcss-loader 0.8.1 0.8.1 perfectraw-loader 0.5.1 0.5.1 perfectrequirejs 2.1.20 2.1.20 perfectsass-loader 3.1.2 3.1.2 perfectscript-loader ^0.6.1 0.6.1 matchsinon 1.15.3 1.15.3 perfectsinon-chai 2.8.0 2.8.0 perfectsource-map-loader 0.1.5 0.1.5 perfectsquirejs 0.2.1 0.2.1 perfectstyle-loader 0.13.0 0.13.0 perfecttime-grunt 1.3.0 1.3.0 perfectuglify-js 2.5.0 2.5.0 perfectunderscore 1.7.0 1.7.0 perfectwebpack 1.12.14 1.12.14 perfectwebpack-dev-server 1.10.1 1.10.1 perfectwebpack-manifest-plugin 0.5.0 0.5.0 perfectwellington-bin 1.0.0 1.0.0 perfect@rmn/ad-block-detector ^1.0.0 1.0.0 match
A dependency specification (a key/value in the dependency
field of your package.json
) can have one of 4 states with the node module actually installed, as specified by the semver
column:
- match - The installed module matches the Semantic Versioning 2.0 spec but is not a perfect match (see next bullet). Philosophically,
whatversions
calls this out to you because I do not recommend allowing ranges in yourpackage.json
. Rogue actors could publish new malicious versions within your expected module's range, or legitimate publishers could publish new minor and patch versions which introduce breaking changes due to expected peer dependencies or other surprising reasons. - perfect - The installed module's version is exactly the same as what you specified. Examples of perfect matches: specified
1.10.1
and actual1.10.1
, specified^1.10.1
and actual1.10.1
, specified>=1.10.1
and actual1.10.1
.1.10.x
and1.10.1
cannot be a perfect match, because thex
stands for any value, meaning there is nothing to match "perfectly". - invalid - The installed module does not match the semver spec and something is wrong.
- missing - The installed module is not, in fact, installed.
API Usage
You can use whatversions
programmatically by installing it locally (npm install whatversions
) and then requiring and running it:
var whatversions = ;whatversions;
Note that it returns a Promises/A+ compliant Promise object (specifically, I am using bluebird).
dependenciesData
will be an object where each key is the name of a given dependency, and the value is an object with the following format:
// The name of the module - intentionally redundant with // the key that goes to this object name: 'module-name' // The specified version from your package.json specified: '^1.0.0' // The actual version installed to your node_modules directory actual: '1.0.1' // The match type - 'perfect', 'match', 'invalid', or 'missing'. // See above section for details on the types match: 'match'
Then, you can do whatever you want with the data.
Contributing
To contribute, feel free to submit a pull request. Please include a description of the changes you made, as well as tests for the code.