Automatically Bumping the NPM Package Semver Patch Version

Ole Ersoy
1 min readMar 6, 2021
Image by Jop Verduin from Pixabay

Updated Version

There’s an updated version of this article here:

Scenario

Before publishing our NPM Package we want to automatically bump the semver patch version.

Approach

We will be using the NPM package @jsdevtools/version-bump-prompt to perform the automatic bump.

In the scripts section add the install script for it, such that users of the package know where the bump command comes from.

"scripts": {
"ig": "npm install -g @jsdevtools/version-bump-prompt"
}

Now to install the bump command globally run npm run ig .

Next add a script that bumps the projects patch version:

"scripts": {
...
"bp": "bump patch"
}

To bump the projects patch version run npm run bp.

--

--