{
    "componentChunkName": "component---src-templates-blog-post-js",
    "path": "/understanding-semantic-versioning/",
    "result": {"data":{"markdownRemark":{"html":"<div class=\"table-of-contents\">\n<ul>\n<li><a href=\"#listing-the-installed-packages\">Listing the installed packages</a></li>\n<li><a href=\"#viewing-registry-info-for-a-package\">Viewing registry info for a package</a></li>\n<li><a href=\"#see-all-the-versions-of-a-package\">See all the versions of a package</a></li>\n<li><a href=\"#upgrading-an-outdated-package\">Upgrading an outdated package</a></li>\n<li><a href=\"#development-dependencies\">Development dependencies</a></li>\n<li><a href=\"#uninstalling-a-package\">Uninstalling a package</a></li>\n</ul>\n</div>\n<p>Semantic Versioning is a set of rules and requirements that dictate how version numbers of packages are assigned and incremented. Under this scheme, version numbers and the way they change convey meaning about the underlying code and what has been modified from one version to the next.</p>\n<p>Consider a version format of X.Y.Z (Major.Minor.Patch)</p>\n<ul>\n<li>Increment the PATCH version when you make backward compatible bug fixes.</li>\n<li>Increase the MINOR version when you add functionality in a backward compatibility manner.</li>\n<li>Increase the MAJOR version when you make incompatible API changes.</li>\n</ul>\n<p>In semantic versioning, the version of a node package has three components as shown below:</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">“gsap” </span><span class=\"mtk6\">:</span><span class=\"mtk1\"> “^3.6.1” // equivalent to 3.x</span></span></span></code></pre>\n<p>The first number (3) is known as the major version. The second number (6) is known as the minor version. The minor version is used to add features that don’t break the existing API. The third number (1) is known as the patch version, which is used for bug fixes.</p>\n<p>For example, if <del>gsap</del> developers find a bug in the current version, they will fix the bug and release a new version 3.6.2., by increasing the patch version number.</p>\n<p>If <del>gsap</del> developers add a new feature, they will release a new version 3.7.0. Note that the patch version is 0, because they haven’t found any bug yet.</p>\n<p>If they release a new feature that could break the applications that depend upon the existing version of gsap, then they will increase the major version. The major version will be 4.0.0.</p>\n<p>The <del>^</del> (caret) character tells npm that we are interested in any version of <del>gsap</del> as long as the major version is 3. Let’s say we store our app that uses <del>gsap</del> version ^3.6.1 in GitHub. Six months later, let’s say that <del>gsap</del> has released a new version ^3.7.2. If we clone that directory and npm install the packages, gsap version ^3.7.2 will be installed in our system.</p>\n<p>Sometimes, instead of <del>^</del>, we might come across ~ (tilde). “~3.6.1” means that we are interested in any version of <del>gsap</del> as long as the major version is 3 and the minor version is 6. The alternative syntax is 3.6.x.</p>\n<p>If you want the exact version, you remove the <del>^</del> or ~ character. So, six months later, if you check out the directory from GitHub and install the packages, you will install the exact version used during the app development six months before.</p>\n<h2 id=\"listing-the-installed-packages\" style=\"position:relative;\"><a href=\"#listing-the-installed-packages\" aria-label=\"listing the installed packages permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Listing the installed packages</h2>\n<p>If you want to find out the list of installed dependencies and their exact version, you can simply run the following command:</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm list</span></span></span></code></pre>\n<p>If you want to see only the dependencies of your application(<em>not their dependencies</em>), you can supply the depth flag to the <del>npm list</del> command as shown below.</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm list --depth=0</span></span></span></code></pre>\n<h2 id=\"viewing-registry-info-for-a-package\" style=\"position:relative;\"><a href=\"#viewing-registry-info-for-a-package\" aria-label=\"viewing registry info for a package permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Viewing registry info for a package</h2>\n<p>If you want to find out all the meta data about let’s say <del>gsap</del>, you can use the following command.</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm view gsap</span></span></span></code></pre>\n<h2 id=\"see-all-the-versions-of-a-package\" style=\"position:relative;\"><a href=\"#see-all-the-versions-of-a-package\" aria-label=\"see all the versions of a package permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>See all the versions of a package</h2>\n<p>If you want to see all the versions of the <del>gsap</del> package released so far, you can use the following command.</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm view gsap versions</span></span></span></code></pre>\n<h2 id=\"upgrading-an-outdated-package\" style=\"position:relative;\"><a href=\"#upgrading-an-outdated-package\" aria-label=\"upgrading an outdated package permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Upgrading an outdated package</h2>\n<p>If you want to find out the outdated packages in your application and their newer versions, you can use the following command:</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm outdated</span></span></span></code></pre>\n<p>If you use the command npm <del>update</del>, only the minor and patch versions will be updated.</p>\n<p>If you want to update to the latest version however, you have to first install the following package.</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm i -g npm-check-updates</span></span></span></code></pre>\n<p>Now, if you run <del>npm-check-updates</del> on the terminal, all the packages will be updated to their latest release. Next, you can update the <del>package.json</del> file using the following command:</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm-check-updates -u</span></span></span></code></pre>\n<p>But you have not installed the package yet. You have just updated the version in <del>package.json</del>. To install the package, run the following command:</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm i</span></span></span></code></pre>\n<h2 id=\"development-dependencies\" style=\"position:relative;\"><a href=\"#development-dependencies\" aria-label=\"development dependencies permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Development dependencies</h2>\n<p>Development dependencies are dependencies that should not go to production environments.</p>\n<p>Supply the following flag to install a package as a development dependency.</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">--save-dev</span></span></span></code></pre>\n<h2 id=\"uninstalling-a-package\" style=\"position:relative;\"><a href=\"#uninstalling-a-package\" aria-label=\"uninstalling a package permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Uninstalling a package</h2>\n<p>If you want to uninstall a package, let's say <del>gsap</del>, you can use the following command:</p>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">npm uninstall gsap or npm un gsap</span></span></span></code></pre>\n<p>This will remove gsap from both the <del>package.json</del> file and the <del>node_modules</del> folder.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    position: relative;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n    line-height: 1.4;\n  }\n  \n  .grvsc-code {\n    display: table;\n  }\n  \n  .grvsc-line {\n    display: table-row;\n    box-sizing: border-box;\n    width: 100%;\n    position: relative;\n  }\n  \n  .grvsc-line > * {\n    position: relative;\n  }\n  \n  .grvsc-gutter-pad {\n    display: table-cell;\n    padding-left: 0.75rem;\n    padding-left: calc(var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem)) / 2);\n  }\n  \n  .grvsc-gutter {\n    display: table-cell;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    user-select: none;\n  }\n  \n  .grvsc-gutter::before {\n    content: attr(data-content);\n  }\n  \n  .grvsc-source {\n    display: table-cell;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-source:empty::after {\n    content: ' ';\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    user-select: none;\n  }\n  \n  .grvsc-gutter + .grvsc-source {\n    padding-left: 0.75rem;\n    padding-left: calc(var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem)) / 2);\n  }\n  \n  /* Line transformer styles */\n  \n  .grvsc-has-line-highlighting > .grvsc-code > .grvsc-line::before {\n    content: ' ';\n    position: absolute;\n    width: 100%;\n  }\n  \n  .grvsc-line-diff-add::before {\n    background-color: var(--grvsc-line-diff-add-background-color, rgba(0, 255, 60, 0.2));\n  }\n  \n  .grvsc-line-diff-del::before {\n    background-color: var(--grvsc-line-diff-del-background-color, rgba(255, 0, 20, 0.2));\n  }\n  \n  .grvsc-line-number {\n    padding: 0 2px;\n    text-align: right;\n    opacity: 0.7;\n  }\n  \n  .synthwave-84 { background-color: #262335; }\n  .synthwave-84 .mtk1 { color: #FFFFFF; }\n  .synthwave-84 .mtk6 { color: #36F9F6; }\n  .synthwave-84 .grvsc-line-highlighted::before {\n    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));\n  }\n</style>","frontmatter":{"title":"Understanding Semantic Versioning (SemVer)","date":"2021-06-10"}}},"pageContext":{"slug":"/understanding-semantic-versioning/","prev":{"fields":{"slug":"/template-literals-in-javascript/"},"frontmatter":{"modules":null}},"next":{"fields":{"slug":"/how-to-build-an-express-graphql-server-part-2/"},"frontmatter":{"modules":null}}}},
    "staticQueryHashes": ["3159585216"]}