• equality: If there is no operator in front of the version number, this is assumed. However, you can still include = if you like. =3.2.1 and 3.2.1 will both expect exactly version 3.2.1.

  • less than/greater than: >=3.2.1 would match 3.2.3, 3.4.7, and also 4.2.7. These are problematic, because they are too broad. Generally, you want to limit yourself to certain versions, to maintain operability.

  • hyphen: You can use - between two versions, that you specify. This is useful if you need to maintain some legacy feature that you know will break at a specific version. For example, 1.3.2 - 2.4.1. This will include both endpoints.

  • X marks the spot: Any of X, x, or * may be used to “stand in” for one of the numeric values.

    • * := >=0.0.0 (Any version satisfies)
    • 1.x := >=1.0.0 <2.0.0 (Matching major version)
    • 1.2.x := >=1.2.0 <1.3.0 (Matching major and minor versions)
  • tilde: The ~ means “approximate version”. This allows for more recent patches, but does not accept any packages with a different minor version. For example, ~2.3.3 will allow values between 2.3.3 and 2.4, not including 2.4. Note that this will allow differences in the minor version is none is specified. ~2 will accept any version that starts with 2.

  • carat: The ^ means “compatible with version,” and is more broad than the tilde. It only refuses changes to the major version. For example, ^3.4.1 will allow any version between that value and 4.0.0, not including version 4.

👉 Source