What is SemVer and NPM?

SemVer and NPM

SemVer stands for Semantic Versioning. NPM stands for Node Package Manager.

Because there can be different versions of a module that is installable, and the need to install various versions can differ, there exists what we call SemVer.

NPM is used to install packages or modules in NodeJS.

What is SemVer?

SemVer is the standard for versioning node packages or modules. It is the reason there are different versions for node modules when you install any package using NPM.

SemVer in action

Let’s install Express.

Do the following using your terminal:

  1. Create a new directory by typing the following command.
mkdir semver
  1. Move into the folder that you just created.
cd semver
  1. Type the following to create your package configuration file once you have moved in.
npm init -y
  1. Finally, install express by typing the following.
npm i express
  1. Head over to your package.json file to find the version number of the installed express package installed.

From the image above, we can see that the version number of the express package we installed is 4.17.1.

Understanding the version of the installed package

4.17.1 = MAJOR.MINOR.PATCH

The 4 refers to MAJOR, the 17 refers to MINOR, and the 1 refers to PATCH.

  • MAJOR – This means that there is a change in API compatibility.
  • MINOR – This means that there is new functionality added and that it is backward compatible.
  • PATCH – This refers to a bug fix. When this part of the version number increases, it means that a bug has been fixed.

Free Resources