16

How to tell the version of the installed RxJS from the code? For example:

var Rx = require('rxjs/Rx');
console.log(Rx.rev);   // undefined
console.log(Rx.version);  // undefined

Second question: How to tell if it's rxjs5 ?

Sohail Si
  • 2,750
  • 2
  • 22
  • 36
  • 1
    Don't check the version, check if the classes and methods you want exist (like a polyfill might do). It's far more flexible. – ssube Sep 23 '16 at 15:24
  • Thanks. I think RxJS may not have backward compatibility (not sure). You are right, but I didn't want to use it in the production code. Just want to report in which version my example is tested. – Sohail Si Sep 23 '16 at 15:37
  • 1
    Nothing wrong with logging some version info, always good to have when debugging. :) – ssube Sep 23 '16 at 15:54

4 Answers4

28

This will show all NPM package versions if you installed with NPM.

npm list --depth=0

If you leave out the --depth then you'll get all their dependencies also.

Preston
  • 3,260
  • 4
  • 37
  • 51
17

You can install the 'version-check' library from npm using

npm install -g version-check

And then call

version-check rxjs

Hope this solves your problem.

Arpan Srivastava
  • 356
  • 5
  • 10
4

You could do something like:

const package = require('rxjs/package.json');
const is5 = /^5\./.test(package.version);

console.log(package.version);
console.log(is5);
Ben Fortune
  • 31,623
  • 10
  • 79
  • 80
1

Try and check on the list

ng --version

Werthis
  • 557
  • 3
  • 15
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 04 '22 at 01:08