How do I install the latest minor version of a package on npm?

mikemaccana picture mikemaccana · Sep 16, 2016 · Viewed 15k times · Source

For example:

  • I have version 2.0.0 of package-name installed.
  • The latest minor version that has the same major version is 2.1.2
  • The latest major version (which would be installed if I ran npm install package-name@latest is 4.3.0

How can I install the most recent package that does not have breaking changes?

Answer

Kevin Danikowski picture Kevin Danikowski · May 24, 2018

Use npm install package-name@"<next-major.0.0"

For example:

npm install package-name@"<3.0.0" would install the latest right before 3.0.0 (e.g. 2.11.1)