I upgraded express.js from 3.2.5 to 3.14.0, and used to output the version like this:
var express = require('express');
console.log("**Express Version: ", express.version);
and would give me
**Express Version: 3.2.5
after I updated to 3.14.0, I get:
**Express Version: undefined
any help? Thanks!
Using @FreeTymeKiyan's answer as well as this answer: https://stackoverflow.com/a/24750985/1696153
I found that I can output the version like so:
console.log("**Express Version: ", require('express/package').version);
I found that version property is removed from express object in 3.14.0. You may check it with console.log(express);
So there is probably no good way to get it with your original code. A workaround is to get the version in package.json file.
var pkgInfo = require('./package.json');
console.log(pkgInfo.dependencies.express);
If there is any strange sign before the version number, try remove that sign at the beginning of the string.
console.log(pkgInfo.dependencies.express.substr(1));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With