10

When trying to install the latest version of RxJS,

I used npm install rxjs as explained in this documentation: https://github.com/reactivex/rxjs

But I got these warnings:

npm warn @angular/common@5.1.0 requires a peer of rxjs@^5.5.0 but none is installed.

You must install peer dependencies yourself.

enter image description here

So it looks like RxJS is upgraded but not to the latest version.

In the output we see that there is a latest one which is RxJS 5.5.0

Is there any better npm command line to upgrade to the latest version ?

Community
  • 1
  • 1
HDJEMAI
  • 9,436
  • 46
  • 67
  • 93

3 Answers3

24

EDIT 2020

The easiest way to force upgrade any package would be to do append an @latest to the required package.

In our use case it would be

npm install rxjs@latest

This would force your current setup to install the latest stable version available.

Bear in mind that the latest version might not always be compatible with all the libraries in use. In case a specific range is needed due to compatibility issues you should install specific versions(e.g for the use case)

npm install rxjs@5.5.0

In the previous answer it was also included the -g flag. This would (as for any npm package installation) install the specified package globally in your system and not only on the current project

Previous Answer

You can always try to force the version by doing

npm install -g rxjs@5.5.0

Or you can have a more modern approach and use yarn :)

NOTE

Since the release of npm 5.x the comment about yarn is no longer necessarily true :)

Hugo Noro
  • 3,145
  • 2
  • 13
  • 19
  • I think the opinions on yarn vs npm aren't relevant, especially if there needs to be a note saying that it might not be true anymore. Also, It may be helpful for others who just copy this to know that the `-g` flag will install this globally. – 8888 Apr 09 '20 at 02:09
  • If you see the date of the answer it was in December 2017. What’s the point of your comment? – Hugo Noro Apr 09 '20 at 08:34
  • This is the accepted answer of a question with 20k views, so it shows up easily in search results. Since this serves as documentation for many developers, especially new ones who might search this question in a search engine, I was hoping to encourage it to be improved. – 8888 Apr 09 '20 at 15:22
  • 1
    Point taken. I will edit the answer. Thank you for the feedback – Hugo Noro Apr 09 '20 at 15:33
0

Npm is telling you that it has found latest version 5.5.0 but your angular 5.1 version is not compatible with RxJs@5.5.0 and hence it falls back to the last compatible. Upgrade your angular version alongside, so that you can leverage features of both You can install latest angular using npm install -g @angular/cli@latest After installation you will need to run npm update in your project

mobby
  • 361
  • 4
  • 8
0

There seems to be some problem with the latest rxjs. You can change to another rxjs version as given below:

npm install rxjs@6.0.0 --save

thedarkgriffen
  • 394
  • 3
  • 16