user3506588 user3506588 - 2 months ago 16x
TypeScript Question

How to extract version information of the dependencies

I was wondering is there a way to extract and print version information of all dependencies?
For example I am using following dependencies:

"dependencies": {
"angular2": "2.0.0-beta.15",
"bu-controls": "^0.0.34",
"es6-shim": "^0.35.0",
"jquery": "^2.2.0",
"moment": "2.14.1",
"ms-signalr-client": "2.2.5",
"ng2-translate": "^1.11.1",
"numeral": "1.5.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "~0.19.18",
"underscore": "1.8.3",
"zone.js": "0.6.10"

So my task is to display version information on the browser for the clients.
Thank you very much, in advance, for your help.


Since you're using npm, you can redirect the output of the command npm list --depth=0 to a file, and then parse the file and display the contents on your webpage in the browser.

Here's an example of what npm list --depth=0 looks like in a project of mine.

+-- @angular/common@2.0.0-rc.5
+-- @angular/compiler@2.0.0-rc.5
+-- @angular/core@2.0.0-rc.5
+-- @angular/forms@0.3.0
+-- @angular/http@2.0.0-rc.5
+-- @angular/platform-browser@2.0.0-rc.5
+-- @angular/platform-browser-dynamic@2.0.0-rc.5
+-- @angular/router@3.0.0-rc.1
+-- @angular/router-deprecated@2.0.0-rc.2
+-- @angular/upgrade@2.0.0-rc.5
+-- angular2-in-memory-web-api@0.0.15
+-- bootstrap@3.3.7
+-- concurrently@2.2.0
+-- core-js@2.4.1
+-- lite-server@2.2.2
+-- reflect-metadata@0.1.8 invalid
+-- rxjs@5.0.0-beta.6
+-- systemjs@0.19.27
+-- typescript@1.8.10
+-- typings@1.3.2
`-- zone.js@0.6.12