Get Module Version in Node.js
Here’s how to extract the version number from your package.json
file. I use this to quickly verify that my current Nodejitsu snapshot is up to date.
// Require package.json like a regular module
var packageInfo = require('./package.json');
// Do something with the version
console.log('VERSION: ' + packageInfo.version);
Happy coding.