DEV Community

Cover image for Understanding Semantic Versioning
Saleem
Saleem

Posted on • Edited on

5 1

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.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay