Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express version output

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!

like image 915
Katie Avatar asked Jan 10 '23 05:01

Katie


2 Answers

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);
like image 198
Katie Avatar answered Jan 16 '23 22:01

Katie


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));
like image 44
FreeTymeKiyan Avatar answered Jan 16 '23 21:01

FreeTymeKiyan