DEV Community

Cover image for Understanding Semantic Versioning
Saleem
Saleem

Posted on • Updated on

Understanding Semantic Versioning

After reading this guide you will have a better understanding of the semantic versioning standard used within a majority of software eco-systems.

Table of Contents

What is in a Version Number?

Alt Text

For the rest of this guide let's assume our current version of our dependency is 1.0.0 .

In the example above the version is divided into 3 components, with 1 being the major component, 0 being the minor component, and 0 being the patch component.

When one of these components are updated this is what it means:

Major: Each major update is not backwards compatible with a previous version, this means that 2.0.0 is substantially different to 1.0.0 that it will break your application using the 1.0.0 version if you don't make changes in how you use this dependancy.

Minor: A minor update introduces non-breaking changes this means that for example, a version of 1.10.0 will not cause your application to break - so no changes are required.

Patch: A patch update also introduces non-breaking changes i.e 1.0.5 will still be able to work fine with your application without having to change a thing.

How this applies to your Application

"dependencies": {
    "my_dep": "^1.0.0",
    "another_dep": "~1.0.0"
  }
Enter fullscreen mode Exit fullscreen mode

The above code snippet is an example of the dependencies section in a package.json file.

Carets( ^ ) and Tildes( ~ )

The caret or the tilde that is in front of the version number determines how the dependancy will be updated when you run "npm update".

^ : this will update the dependency to the latest minor version available. i.e if 1.10.0 is the latest minor version - your dependency will be updated to that version.

~ : this will update the dependency to the latest patch version available. i.e 1.0.10

Note: Using "npm update" will not automatically update to the next major version (2.0.0) - you will have to manually update the package.json to the next major version and then fix your codebase of the breaking changes.

Thanks

I hope this helps - feel free to comment or ask questions.

Oldest comments (0)