Skip to content
Home » Major minor and patch release in package.json

Major minor and patch release in package.json

Major minor and patch release in package.json

In this article, we will learn about the difference between Major minor and patch release in package.json configuration.


What is package.json (In short)

  • It’ is a central repository of configuration for different package management tools for an application.
  • It’s a place where tools like npm/yarn store the names and versions of the packages to install and manage.

Differences between Major, Minor and patch versions

Our main focus here is on the property name ‘version’.

  • The version property indicates the current version of a package.
  • It is always expressed with 3 numbers in the format x.y.z for example 1.1.4
  • So in the format x.y.z:
    • x is the major version number,
    • y is the minor version number, and
    • z is the patch version number.

Meaning of each of the above 3 types of version number

  • Major release version: If there are any Major changes like breaking changes or new features in a package then a release is done by updating this major version number.
  • Minor release version: If there are any changes related to a backward-compatible or deprecating any features then a release is done by updating this minor version number.
  • Patch release version: If there are only bug fixes then a release is done by updating this minor version number.

How to get only Major or Minor or Patch updates

In the above sections, we saw the meaning of each of the numbers in the semantic versioning notation for ‘version’ and when to update specific version numbers based on the release type like Major, Minor, or patch updates.

But it is also very necessary to understand how to tell the package.json file to update only the intended type of release(Major, Minor, or patch) because of some of the reasons like:

  • With package dependencies, it can happen that one package is updated with the major release version while the dependency package is still not updated to its major release version and only updated to the patch version.
  • If the package is set to get updated with Major releases then the update may break the application if the code written based on the previous release is not compatible with the newly released version.

So let’s see how to use package versioning in the pacakge.json file to get only specific types of release updates for any package.

Certain symbols are used in front of the version number like ~1.0.2 or ^0.1.5 to instruct the pacakge.json that a package can be updated with what type of release whenever a new update is available for a package.

  1. ~ : (Example: "grunt": "~0.1.3")
    • Install/update the package with only patch releases.
    • So package will be updated with patch updates like 0.1.4, 0.1.5, 0.1.6, etc but minor or major updates like 0.2.3, 1.1.4, etc will not be considered.
  2. ^ : (Example: "grunt": "^0.1.3")
    • Install/update the package with only minor and patch releases.
    • So package will be updated with patch/minor updates like 0.1.4, 0.1.5, 0.2.3, 0.2.4, etc will be updated but major updates like 1.1.3, 2.2.4, etc will not be considered.
  3. * : (Example: "grunt": "*0.1.3")
    • Install/update the package with all types of releases.
    • So package will be updated with all updates like 0.1.4, 0.2.4, 0.2.3, 1.1.3, 2.2.4, etc will be considered.
  4. > : (Example: "grunt": ">0.1.3")
    • Install/update the package with any version greater than the specified version.
  5. >= : (Example: "grunt": ">=0.1.3")
    • Install/update the package with any version greater than or equal to the specified version.
  6. < : (Example: "grunt": "<0.1.3")
    • Install/update the package with any version less than the specified version.
  7. <= : (Example: "grunt": "<=0.1.3")
    • Install/update the package with any version less than or equal to the specified version.
  8. no symbol: (Example: "grunt": "0.1.3")
    • Install/update the package with the specified version.
  9. latest: (Example: "grunt": "latest")
    • Install/update the package with the latest version available.

I hope you like this article and helps you to solve your problems.

Visit Techtalkbook to find more related topics.


Leave a Reply

Your email address will not be published. Required fields are marked *

1 Shares
Tweet
Pin1
Share
Share
Share